Submission #1689849
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
int solve(int*data,int n,int weight,int count,int x,int max){
if(weight==x)return count+1;
if(weight>x)return 0;
if(n==max)return 0;
int w=weight+data[n];
if(weight!=x && w > x)return count;
int a=solve(data,n+1,weight,count,x,max);
int b=solve(data,n+1,w,count,x,max);
return a+b;
}
int main(void){
int n,x;
scanf("%d %d",&n,&x);
int*data=new int[n];
for(int i=0;i<n;i++){
scanf("%d",&data[i]);
}
int count=0;
sort(data,data+n);
cout<<solve(data,0,0,0,x,n)<<endl;
return 0;
}
Submission Info
Submission Time
2017-10-17 14:07:03+0900
Task
C - 無駄なものが嫌いな人
User
shumy
Language
C++14 (GCC 5.4.1)
Score
0
Code Size
582 Byte
Status
TLE
Exec Time
2103 ms
Memory
256 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:15: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:18:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&data[i]);
^
Judge Result
Set Name
All
Score / Max Score
0 / 100
Status
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
2103 ms
256 KB
max_2.txt
TLE
2103 ms
256 KB
max_3.txt
TLE
2103 ms
256 KB
max_4.txt
TLE
2103 ms
256 KB
pair_1.txt
TLE
2103 ms
256 KB
pair_2.txt
TLE
2103 ms
256 KB
power2_1.txt
TLE
2103 ms
256 KB
power2_2.txt
TLE
2103 ms
256 KB
power2_3.txt
TLE
2103 ms
256 KB
power2_4.txt
TLE
2103 ms
256 KB
power2_5.txt
AC
161 ms
256 KB
random_1.txt
TLE
2103 ms
256 KB
random_2.txt
TLE
2103 ms
256 KB
random_3.txt
AC
5 ms
256 KB
random_4.txt
TLE
2103 ms
256 KB
random_5.txt
AC
388 ms
256 KB
random_6.txt
TLE
2103 ms
256 KB
random_7.txt
TLE
2103 ms
256 KB
random_8.txt
TLE
2103 ms
256 KB
random_9.txt
AC
98 ms
256 KB
sample_1.txt
AC
1 ms
256 KB
sample_2.txt
AC
1 ms
256 KB
sample_3.txt
AC
1 ms
256 KB
sample_4.txt
AC
2 ms
256 KB
small_1.txt
AC
1 ms
256 KB
small_2.txt
AC
1 ms
256 KB
small_3.txt
AC
1 ms
256 KB
small_4.txt
AC
1 ms
256 KB