Submission #1689942


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
map<int,int> solve(int*data,int n){
  vector<int>t;
  t.push_back(0);
  t.push_back(data[0]);  
  for(int i=1;i<n;i++){
    int size=t.size();
    for(int j=0;j<size;j++){
      t.push_back(t[j]+data[i]);
    }
  }
  sort(t.begin(),t.end());
  int prev=-1;
  map<int,int>d;
  for(int i=0;i<data[n-1];i++){
    d[i]=0;
  }
  for(int i=0;i<t.size();i++){
    d[t[i]]++;
  }
  
  return d;
}
int main(void){
  int n,x;
  scanf("%d %d",&n,&x);
  int*data=new int[n];
  int*data2=new int[n];
  int size=0;
  int size2=0;
  for(int i=0;i<n;i++){
    if((i%2)==0){
      scanf("%d",&data[size]);
      size++;
    }else{
      scanf("%d",&data2[size2]);
      size2++;
    }
  }
  map<int,int>a=solve(data,size);
  map<int,int>b=solve(data2,size2);
  int count=0;
  for(int i=1;i<x;i++){
    count+=(a[i]*b[x-i]);
  }
  count+=a[x];
  count+=b[x];
  cout<<count<<endl;
  return 0;
}

Submission Info

Submission Time
Task C - 無駄なものが嫌いな人
User shumy
Language C++14 (GCC 5.4.1)
Score 0
Code Size 970 Byte
Status TLE
Exec Time 2119 ms
Memory 246264 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:27:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&n,&x);
                       ^
./Main.cpp:34:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d",&data[size]);
                              ^
./Main.cpp:37:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d",&data2[size2]);
                                ^

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 11
TLE × 17
Set Name Test Cases
All max_1.txt, max_2.txt, max_3.txt, max_4.txt, pair_1.txt, pair_2.txt, power2_1.txt, power2_2.txt, power2_3.txt, power2_4.txt, power2_5.txt, random_1.txt, random_2.txt, random_3.txt, random_4.txt, random_5.txt, random_6.txt, random_7.txt, random_8.txt, random_9.txt, sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt, small_1.txt, small_2.txt, small_3.txt, small_4.txt
Case Name Status Exec Time Memory
max_1.txt TLE 2115 ms 193148 KB
max_2.txt TLE 2115 ms 190588 KB
max_3.txt TLE 2115 ms 195964 KB
max_4.txt AC 7 ms 760 KB
pair_1.txt TLE 2116 ms 191868 KB
pair_2.txt TLE 2116 ms 191612 KB
power2_1.txt TLE 2119 ms 246264 KB
power2_2.txt AC 15 ms 1784 KB
power2_3.txt TLE 2115 ms 191228 KB
power2_4.txt AC 7 ms 760 KB
power2_5.txt TLE 2119 ms 190080 KB
random_1.txt TLE 2117 ms 189948 KB
random_2.txt TLE 2115 ms 191612 KB
random_3.txt TLE 2116 ms 195068 KB
random_4.txt TLE 2114 ms 191484 KB
random_5.txt AC 9 ms 760 KB
random_6.txt AC 7 ms 640 KB
random_7.txt TLE 2114 ms 191740 KB
random_8.txt TLE 2117 ms 189692 KB
random_9.txt TLE 2115 ms 183932 KB
sample_1.txt AC 1 ms 256 KB
sample_2.txt AC 1 ms 256 KB
sample_3.txt TLE 2116 ms 192128 KB
sample_4.txt AC 1 ms 256 KB
small_1.txt TLE 2116 ms 195712 KB
small_2.txt AC 1492 ms 115968 KB
small_3.txt AC 1 ms 256 KB
small_4.txt AC 1 ms 256 KB