Submission #855006


Source Code Expand

Copy
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
ll f[55][55][2555];
int main() {
	ios_base::sync_with_stdio(false);
	ll n,a; cin>>n>>a;
	ll v[55];
	for (ll i=0;i<n;i++) cin>>v[i];
	f[0][0][0]=1;
	for (ll x=0;x<n;x++) {
		ll val=v[x];
		for (ll c=0;c<=n;c++) {
			for (ll y=0;y<2555;y++) {
				ll ways=f[x][c][y];
				f[x+1][c][y]+=ways;
				if(y+val<2555) f[x+1][c+1][y+val]+=ways;
			}
		}
	}
	ll ans=0;
	for (ll c=1;c<=n;c++) {
		ll want=c*a;
		ans+=f[n][c][want];
	}
	cout<<ans<<endl;

}

Submission Info

Submission Time
Task C - Tak and Cards
User LiChenKoh
Language C++14 (GCC 5.4.1)
Score 300
Code Size 910 Byte
Status AC
Exec Time 100 ms
Memory 52352 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 5 ms 768 KB
example_02.txt AC 5 ms 512 KB
example_03.txt AC 6 ms 1920 KB
example_04.txt AC 47 ms 23424 KB
subtask1_01.txt AC 14 ms 6016 KB
subtask1_02.txt AC 14 ms 6016 KB
subtask1_03.txt AC 14 ms 6016 KB
subtask1_04.txt AC 14 ms 6016 KB
subtask1_05.txt AC 16 ms 6016 KB
subtask1_06.txt AC 5 ms 256 KB
subtask1_07.txt AC 4 ms 256 KB
subtask1_08.txt AC 15 ms 6016 KB
subtask1_09.txt AC 14 ms 5376 KB
subtask2_01.txt AC 88 ms 52352 KB
subtask2_02.txt AC 90 ms 52352 KB
subtask2_03.txt AC 93 ms 50304 KB
subtask2_04.txt AC 88 ms 52352 KB
subtask2_05.txt AC 100 ms 52352 KB
subtask2_06.txt AC 100 ms 52352 KB
subtask2_07.txt AC 89 ms 52352 KB
subtask2_08.txt AC 43 ms 23424 KB
subtask2_09.txt AC 43 ms 23424 KB
subtask2_10.txt AC 69 ms 35584 KB
subtask2_11.txt AC 76 ms 39040 KB