Submission #1515592


Source Code Expand

#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
int n,x,w[40];

int saiki(int i,int s){
    if(i == n){
        return s == 0;
    }
    if(s == 0)
        return 1;
    if(s < 0)
        return 0;
    if((n - i) * w[i] < s)
        return 0;

    return saiki(i + 1,s) + saiki(i + 1,s - w[i]);
}

int main(){
    scanf("%d%d",&n,&x);
    REP(i,n)
        scanf("%d",w + i);
    sort(w,w + n,greater<int>());
    printf("%d\n",saiki(0,x));
    return 0;
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:33:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&x);
                        ^
./Main.cpp:35:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",w + i);
                          ^

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 20
TLE × 8
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 AC 1005 ms 256 KB
pair_1.txt AC 909 ms 256 KB
pair_2.txt TLE 2103 ms 256 KB
power2_1.txt AC 1 ms 256 KB
power2_2.txt AC 3 ms 256 KB
power2_3.txt AC 295 ms 256 KB
power2_4.txt AC 856 ms 256 KB
power2_5.txt AC 1 ms 256 KB
random_1.txt TLE 2103 ms 256 KB
random_2.txt AC 211 ms 256 KB
random_3.txt AC 3 ms 256 KB
random_4.txt TLE 2103 ms 256 KB
random_5.txt AC 120 ms 256 KB
random_6.txt AC 193 ms 256 KB
random_7.txt TLE 2103 ms 256 KB
random_8.txt TLE 2103 ms 256 KB
random_9.txt AC 136 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 1 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