Submission #855020


Source Code Expand

Copy
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

ll dp[51][51][2501];

int main(){
    int N, A;
    cin >> N >> A;
    vi x(N);
    rep(i, N)scanf("%d", &x[i]);

    dp[0][0][0] = 1;
    rep(i, N)rep(j, N)rep(k, 2501){
        ll y = dp[i][j][k];
        if(y == 0)continue;
        dp[i + 1][j + 1][k + x[i]] += y;
        dp[i + 1][j][k] += y;
    }

    ll ans = 0;
    FOR(n, 1, N + 1)rep(sm, 2501){
        if(sm%n == 0 && sm / n == A){
            ans += dp[N][n][sm];
        }
    }
    cout << ans << endl;
}

Submission Info

Submission Time
Task C - Tak and Cards
User paruki
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1019 Byte
Status AC
Exec Time 55 ms
Memory 9600 KB

Compile Error

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

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 100 / 100
Status
AC × 4
AC × 12
AC × 24
Set Name Test Cases
Sample example_01.txt, example_02.txt, example_03.txt, example_04.txt
Subtask1 example_01.txt, example_02.txt, example_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt
All example_01.txt, example_02.txt, example_03.txt, example_04.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt
Case Name Status Exec Time Memory
example_01.txt AC 4 ms 256 KB
example_02.txt AC 4 ms 256 KB
example_03.txt AC 5 ms 384 KB
example_04.txt AC 23 ms 2560 KB
subtask1_01.txt AC 9 ms 896 KB
subtask1_02.txt AC 10 ms 896 KB
subtask1_03.txt AC 9 ms 896 KB
subtask1_04.txt AC 9 ms 896 KB
subtask1_05.txt AC 9 ms 1024 KB
subtask1_06.txt AC 4 ms 256 KB
subtask1_07.txt AC 4 ms 256 KB
subtask1_08.txt AC 9 ms 896 KB
subtask1_09.txt AC 8 ms 896 KB
subtask2_01.txt AC 48 ms 8320 KB
subtask2_02.txt AC 49 ms 8320 KB
subtask2_03.txt AC 52 ms 7808 KB
subtask2_04.txt AC 46 ms 5504 KB
subtask2_05.txt AC 46 ms 5504 KB
subtask2_06.txt AC 46 ms 5504 KB
subtask2_07.txt AC 55 ms 9600 KB
subtask2_08.txt AC 26 ms 3328 KB
subtask2_09.txt AC 27 ms 3456 KB
subtask2_10.txt AC 38 ms 5376 KB
subtask2_11.txt AC 41 ms 6144 KB