Submission #856786


Source Code Expand

Copy
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <tuple>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;


ll const mod = 1e9 + 7;
int n, a;

ll dp[51][51][2570]; // iコメまでからj個選んで和をkにする

int main() {
    int x[55];
    while (cin >> n >> a) {
        int s = 0;
        for (int i = 0; i < n; i++) {
            cin >> x[i];
            s += x[i];
        }

        memset(dp, 0, sizeof dp);
        dp[0][0][0] = 1;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j <= i; j++) {
                for (int k = 0; k <= s; k++) {
                    dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
                    dp[i + 1][j][k] += dp[i][j][k];
                }
            }
        }
        ll ans = 0;
        for (int i = 1; i <= n; ++i) {
            ans += dp[n][i][i*a];
        }
        cout << ans << endl;
    }
}

Submission Info

Submission Time
Task C - Tak and Cards
User tubo28
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1542 Byte
Status AC
Exec Time 84 ms
Memory 52480 KB

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 74 ms 52480 KB
example_02.txt AC 74 ms 52480 KB
example_03.txt AC 74 ms 52480 KB
example_04.txt AC 74 ms 52480 KB
subtask1_01.txt AC 75 ms 52480 KB
subtask1_02.txt AC 75 ms 52480 KB
subtask1_03.txt AC 74 ms 52480 KB
subtask1_04.txt AC 75 ms 52480 KB
subtask1_05.txt AC 75 ms 52480 KB
subtask1_06.txt AC 75 ms 52480 KB
subtask1_07.txt AC 74 ms 52480 KB
subtask1_08.txt AC 74 ms 52480 KB
subtask1_09.txt AC 74 ms 52480 KB
subtask2_01.txt AC 80 ms 52480 KB
subtask2_02.txt AC 80 ms 52480 KB
subtask2_03.txt AC 79 ms 52480 KB
subtask2_04.txt AC 84 ms 52480 KB
subtask2_05.txt AC 84 ms 52480 KB
subtask2_06.txt AC 75 ms 52480 KB
subtask2_07.txt AC 83 ms 52480 KB
subtask2_08.txt AC 76 ms 52480 KB
subtask2_09.txt AC 76 ms 52480 KB
subtask2_10.txt AC 78 ms 52480 KB
subtask2_11.txt AC 78 ms 52480 KB