Submission #14017997


Source Code Expand

Copy
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

int main() {
    int N, A;
    cin >> N >> A;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    
    vector<vector<vector<lint>>> dp(N + 1, vector<vector<lint>>(N + 1, vector<lint>(2510, 0)));
    dp[0][0][0] = 1;
    rep(i, N) rep(j, N + 1) rep(k, 2510) {
        dp[i + 1][j][k] += dp[i][j][k];
        if (j + 1 <= N && k + a[i] <= 2500) dp[i + 1][j + 1][k + a[i]] += dp[i][j][k];
    }
    lint ans = 0;
    for (int i = 1; i <= N; ++i) ans += dp[N][i][A * i];
    cout << ans << "\n";
    return 0;
}

Submission Info

Submission Time
Task C - Tak and Cards
User Forested
Language C++14 (GCC 5.4.1)
Score 300
Code Size 851 Byte
Status
Exec Time 38 ms
Memory 52352 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 example_01.txt, example_02.txt, example_03.txt, example_04.txt
Subtask1 200 / 200 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 100 / 100 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 2 ms 896 KB
example_02.txt 1 ms 640 KB
example_03.txt 2 ms 2048 KB
example_04.txt 18 ms 23680 KB
subtask1_01.txt 5 ms 6272 KB
subtask1_02.txt 5 ms 6272 KB
subtask1_03.txt 5 ms 6272 KB
subtask1_04.txt 5 ms 6272 KB
subtask1_05.txt 5 ms 6272 KB
subtask1_06.txt 1 ms 384 KB
subtask1_07.txt 1 ms 384 KB
subtask1_08.txt 5 ms 6272 KB
subtask1_09.txt 5 ms 5632 KB
subtask2_01.txt 38 ms 52352 KB
subtask2_02.txt 38 ms 52352 KB
subtask2_03.txt 36 ms 50432 KB
subtask2_04.txt 38 ms 52352 KB
subtask2_05.txt 38 ms 52352 KB
subtask2_06.txt 38 ms 52352 KB
subtask2_07.txt 38 ms 52352 KB
subtask2_08.txt 18 ms 23680 KB
subtask2_09.txt 18 ms 23680 KB
subtask2_10.txt 26 ms 35712 KB
subtask2_11.txt 29 ms 39168 KB