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

Submission #855251

Source Code Expand

Copy
```#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
ll n, a, dp[55][55][2555];
vi x;

ll solve(int i, int used, int sum)
{
if (i == n) return sum == used*a;
if (dp[i][used][sum] >= 0) return dp[i][used][sum];
ll res = 0;
res = solve(i + 1, used + 1, sum + x[i]) + solve(i + 1, used, sum);
return dp[i][used][sum] = res;
}

int main()
{
cin.sync_with_stdio(false);
MS(dp, -1);
cin >> n >> a;
x.resize(n);
REP(i, n) cin >> x[i];
cout << solve(0, 0, 0) - 1 << endl;
return 0;
}```

#### Submission Info

Submission Time 2016-08-28 21:12:53+0900 C - Tak and Cards buttyuki C++14 (GCC 5.4.1) 300 1111 Byte AC 107 ms 60672 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 98 ms 60672 KB
example_02.txt AC 99 ms 60672 KB
example_03.txt AC 99 ms 60672 KB
example_04.txt AC 99 ms 60672 KB
subtask1_01.txt AC 99 ms 60672 KB
subtask1_02.txt AC 99 ms 60672 KB
subtask1_03.txt AC 98 ms 60672 KB
subtask1_04.txt AC 98 ms 60672 KB
subtask1_05.txt AC 99 ms 60672 KB
subtask1_06.txt AC 98 ms 60672 KB
subtask1_07.txt AC 99 ms 60672 KB
subtask1_08.txt AC 99 ms 60672 KB
subtask1_09.txt AC 99 ms 60672 KB
subtask2_01.txt AC 106 ms 60672 KB
subtask2_02.txt AC 107 ms 60672 KB
subtask2_03.txt AC 105 ms 60672 KB
subtask2_04.txt AC 98 ms 60672 KB
subtask2_05.txt AC 98 ms 60672 KB
subtask2_06.txt AC 98 ms 60672 KB
subtask2_07.txt AC 99 ms 60672 KB
subtask2_08.txt AC 101 ms 60672 KB
subtask2_09.txt AC 101 ms 60672 KB
subtask2_10.txt AC 104 ms 60672 KB
subtask2_11.txt AC 104 ms 60672 KB