Submission #57837


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,x;
cin>>n>>x;
vint a(n);
int dp[50][10000]={},sum=0;
rep(i,n){
cin>>a[i];
sum+=a[i];
}
dp[1][a[0]]=1;
REP(i,1,n){
REP(j,1,sum){
if(a[i]==j){
dp[i+1][j]++;
}
if(dp[i][j]>0){
dp[i+1][j+a[i]]+=dp[i][j];
dp[i+1][j]+=dp[i][j];
}
}
}
cout<<dp[n][x]<<'\n';
return(0);
}

ステータス

項目 データ
問題 1235 - チーム虚無新人賞おめでとう!
ユーザー名 ei1918
投稿日時 2019-12-25 12:46:29
言語 C++14
状態 Accepted
得点 100
ソースコード長 999 Byte
最大実行時間 34 ms
最大メモリ使用量 2656 KB

セット

セット 得点 Cases
1 R1910 1 / 1 in01.text, in02.text, in03.text, in04.text, in05.text, in06.text, in07.text, in08.text, in09.text, in10.text, in11.text, in12.text, in13.text, in14.text, in15.text, in16.text, in17.text, in18.text, in19.text, in20.text
2 R1933 9 / 9 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.text AC 30 ms 2524 KB
1
2
in02.text AC 18 ms 2576 KB
1
2
in03.text AC 28 ms 2376 KB
1
2
in04.text AC 16 ms 2436 KB
1
2
in05.text AC 24 ms 2492 KB
1
2
in06.text AC 22 ms 2416 KB
1
2
in07.text AC 18 ms 2472 KB
1
2
in08.text AC 20 ms 2656 KB
1
2
in09.text AC 16 ms 2456 KB
1
2
in10.text AC 24 ms 2512 KB
1
2
in11.text AC 25 ms 2560 KB
1
2
in12.text AC 24 ms 2620 KB
1
2
in13.text AC 19 ms 2424 KB
1
2
in14.text AC 25 ms 2480 KB
1
2
in15.text AC 34 ms 2536 KB
1
2
in16.text AC 20 ms 2592 KB
1
2
in17.text AC 28 ms 2388 KB
1
2
in18.text AC 25 ms 2448 KB
1
2
in19.text AC 21 ms 2500 KB
1
2
in20.text AC 24 ms 2432 KB
1
2
in21.text AC 25 ms 2492 KB
2
in22.text AC 18 ms 2552 KB
2
in23.text AC 24 ms 2604 KB
2
in24.text AC 29 ms 2532 KB
2
in25.text AC 16 ms 2464 KB
2
in26.text AC 27 ms 2524 KB
2
in27.text AC 22 ms 2576 KB
2
in28.text AC 21 ms 2628 KB
2
in29.text AC 21 ms 2556 KB
2
in30.text AC 17 ms 2608 KB
2