Submission #2226438
Source Code Expand
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <cstring>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll INFLL = 1LL<<62;
const double EPS = 1e-12;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) (0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false
//debug
#define DEBUG
#define DUMPOUT cout
#ifdef DEBUG
#define dump(...) DUMPOUT<<#__VA_ARGS__<<" :["<<__FUNCTION__<<":"<<__LINE__<<"]"<<endl; DUMPOUT<<" "; dump_func(__VA_ARGS__)
#else
#define dump(...)
#endif
void dump_func() {DUMPOUT << endl;};
template <class Head, class... Tail> void dump_func(Head&& head, Tail&&... tail) {
DUMPOUT << head;
if (sizeof...(Tail) == 0) DUMPOUT << " ";
else DUMPOUT << ", ";
dump_func(std::move(tail)...);
}
//ostream
template<typename T> ostream& operator << (ostream& os, vector<T>& vec) {
os << "["; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "]";
return os;
}
template<typename T, typename U> ostream& operator << (ostream& os, pair<T, U>& pair_var) {
os << "(" << pair_var.first << ", " << pair_var.second << ")";
return os;
}
template<typename T, typename U> ostream& operator << (ostream& os, map<T, U>& map_var) {
os << "[";
for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
os << "(" << itr->first << ", " << itr->second << ")"; itr++; if(itr != map_var.end()) os << ", "; itr--;
}
os << "]";
return os;
}
template<typename T> ostream& operator << (ostream& os, set<T>& set_var) {
os << "[";
for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
os << *itr; ++itr; if(itr != set_var.end()) os << ", "; itr--;
}
os << "]";
return os;
}
int n, a;
int x[55], dp[55][2505][55];
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n >> a;
int sum = 0;
rep(i, n) {
cin >> x[i];
sum += x[i];
}
dp[0][0][0] = 1;
rep(i, n)rep(j, sum + 1)rep(k, n + 1) {
dp[i + 1][j][k] += dp[i][j][k];
if (j >= x[i] && k >= 1) dp[i + 1][j][k] += dp[i][j - x[i]][k - 1];
}
int ans = 0;
rep2(j, 1, sum + 1)rep2(k, 1, n + 1) {
if (j == k * a) ans += dp[n][j][k];
}
cout << ans << endl;
}
Submission Info
Submission Time |
|
Task |
C - Tak and Cards |
User |
roto_37 |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
3956 Byte |
Status |
AC |
Exec Time |
27 ms |
Memory |
54528 KB |
Judge Result
Set Name |
Sample |
Subtask1 |
All |
Score / Max Score |
0 / 0 |
200 / 200 |
100 / 100 |
Status |
|
|
|
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 |
2 ms |
4352 KB |
example_02.txt |
AC |
2 ms |
2304 KB |
example_03.txt |
AC |
3 ms |
8448 KB |
example_04.txt |
AC |
8 ms |
35072 KB |
subtask1_01.txt |
AC |
5 ms |
16896 KB |
subtask1_02.txt |
AC |
5 ms |
17024 KB |
subtask1_03.txt |
AC |
5 ms |
17024 KB |
subtask1_04.txt |
AC |
4 ms |
16640 KB |
subtask1_05.txt |
AC |
5 ms |
16768 KB |
subtask1_06.txt |
AC |
1 ms |
256 KB |
subtask1_07.txt |
AC |
1 ms |
256 KB |
subtask1_08.txt |
AC |
5 ms |
16896 KB |
subtask1_09.txt |
AC |
4 ms |
14720 KB |
subtask2_01.txt |
AC |
19 ms |
54016 KB |
subtask2_02.txt |
AC |
19 ms |
54016 KB |
subtask2_03.txt |
AC |
19 ms |
54016 KB |
subtask2_04.txt |
AC |
27 ms |
54528 KB |
subtask2_05.txt |
AC |
27 ms |
54528 KB |
subtask2_06.txt |
AC |
12 ms |
53504 KB |
subtask2_07.txt |
AC |
19 ms |
54016 KB |
subtask2_08.txt |
AC |
10 ms |
35328 KB |
subtask2_09.txt |
AC |
11 ms |
35456 KB |
subtask2_10.txt |
AC |
14 ms |
43776 KB |
subtask2_11.txt |
AC |
15 ms |
45824 KB |