Contest Duration: - (local time) (100 minutes) Back to Home

Submission #857689

Source Code Expand

Copy
```#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <list>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iterator>
#include <limits>

#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define ALL(a) (a).begin(),(a).end()
#define RALL(A) (a).rbegin(),(a).rend()
#define PB push_back
#define MP make_pair

#define dump(x) cerr << #x << " = " << (x) << endl;

using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

const int N_MAX = 50;
const int X_MAX = 50;
int N, A;
int x_max;
VI X;

LL dp[N_MAX + 1][N_MAX + 1][N_MAX * X_MAX + 1]; // n, i, sum

void solve() {
REP(j, N + 1) {
REP(k, N + 1) {
REP(s, N * x_max + 1) {
if (j == 0 and k == 0 and s == 0) {
dp[j][k][s] = 1;
} else {
if (j >= 1 and s < X[j]) {
dp[j][k][s] = dp[j-1][k][s];
} else if (j >= 1 and k >= 1 and s >= X[j]) {
dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-X[j]];
} else {
dp[j][k][s] = 0;
}
}
}
}
}
LL ans = 0;
FOR(k, 1, N + 1) {
ans += dp[N][k][k * A];
}
cout << ans << endl;
/*
REP(i, N + 1) {
REP(j, N + 1) {
REP(x, N * x_max + 1) {
cout << dp[i][j][x] << " ";
}
cout << endl;
}
}
*/
}

int main(int argc, char const* argv[])
{
cin >> N >> A;
x_max = A;
int x;
X.PB(-1);
REP(i, N) {
cin >> x;
X.PB(x);
x_max = max(x_max, x);
}
solve();
return 0;
}
```

#### Submission Info

Submission Time 2016-08-29 00:13:02+0900 C - Tak and Cards poyodr C++14 (GCC 5.4.1) 300 2241 Byte AC 107 ms 51072 KB

#### Judge Result

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
Case Name Status Exec Time Memory
example_01.txt AC 4 ms 384 KB
example_02.txt AC 4 ms 256 KB
example_03.txt AC 5 ms 640 KB
example_04.txt AC 14 ms 5760 KB
subtask1_01.txt AC 9 ms 3200 KB
subtask1_02.txt AC 9 ms 3200 KB
subtask1_03.txt AC 10 ms 3200 KB
subtask1_04.txt AC 10 ms 3200 KB
subtask1_05.txt AC 9 ms 3200 KB
subtask1_06.txt AC 4 ms 256 KB
subtask1_07.txt AC 4 ms 256 KB
subtask1_08.txt AC 9 ms 3200 KB
subtask1_09.txt AC 9 ms 2688 KB
subtask2_01.txt AC 106 ms 51072 KB
subtask2_02.txt AC 107 ms 51072 KB
subtask2_03.txt AC 91 ms 49280 KB
subtask2_04.txt AC 106 ms 51072 KB
subtask2_05.txt AC 106 ms 51072 KB
subtask2_06.txt AC 99 ms 51072 KB
subtask2_07.txt AC 97 ms 51072 KB
subtask2_08.txt AC 42 ms 19712 KB
subtask2_09.txt AC 42 ms 19712 KB
subtask2_10.txt AC 65 ms 34688 KB
subtask2_11.txt AC 71 ms 38144 KB