Submission #00004
ソースコード
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 39 40 41 42 43 44 45 46 47 48 | #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair< int , int > Pii; typedef vector< int > Vi; typedef vector<Pii> Vp; #define pb push_back #define eb emplace_back #define fi first #define se second #define mkp make_pair #define All(v) (v).begin(), (v).end() #define rep(i,n) for(int i=0; i<(n); ++i) #define reps(i,f,n) for(int i=(f); i<=(n); ++i) #define debug(x) cerr << #x << ':' << x << endl #define outl(x) cout << x << '\n' #define INF (1 << 29) #define FAST cin.tie(0), ios::sync_with_stdio(false) inline int chmax( int &a, int b){ return b>a ? a=b,1 : 0;} inline int chmin( int &a, int b){ return b<a ? a=b,1 : 0;} //________ int n,x; int a[102]; int mem[102][100010]; int slv( int ix, int sum){ if (sum == x) return 0; if (ix == n) return INF; if (mem[ix][sum] != -1) return mem[ix][sum]; return mem[ix][sum] = min(slv(ix+1,sum+a[ix])+1, slv(ix+1, sum)); } main(){ FAST; rep(i,102){ rep(j,100010)mem[i][j] = -1; } cin >> n >> x; rep(i,n)cin >> a[i]; int ans = slv(0,0); if (ans == INF)outl( "MURI!w" ); else outl(ans); } |
ステータス
項目 | データ |
---|---|
問題 | 0001 - 値の使用回数 |
ユーザー名 | Arumakan_ei1727 |
投稿日時 | 2017-11-15 16:38:22 |
言語 | C++11 |
状態 | Accepted |
得点 | 100 |
ソースコード長 | 1132 Byte |
最大実行時間 | 50 ms |
最大メモリ使用量 | 40680 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 100 / 100 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
input01 | AC | 23 ms | 40288 KB |
1
|
input02 | AC | 30 ms | 40208 KB |
1
|
input03 | AC | 25 ms | 40256 KB |
1
|
input04 | AC | 25 ms | 40300 KB |
1
|
input05 | AC | 25 ms | 40340 KB |
1
|
input06 | AC | 23 ms | 40384 KB |
1
|
input07 | AC | 25 ms | 40428 KB |
1
|
input08 | AC | 23 ms | 40344 KB |
1
|
input09 | AC | 20 ms | 40264 KB |
1
|
input10 | AC | 24 ms | 40316 KB |
1
|
input11 | AC | 30 ms | 40364 KB |
1
|
input12 | AC | 25 ms | 40412 KB |
1
|
input13 | AC | 24 ms | 40460 KB |
1
|
input14 | AC | 21 ms | 40504 KB |
1
|
input15 | AC | 30 ms | 40548 KB |
1
|
input16 | AC | 28 ms | 40600 KB |
1
|
input17 | AC | 24 ms | 40384 KB |
1
|
input18 | AC | 28 ms | 40428 KB |
1
|
input19 | AC | 25 ms | 40476 KB |
1
|
input20 | AC | 21 ms | 40524 KB |
1
|
input21 | AC | 27 ms | 40576 KB |
1
|
input22 | AC | 29 ms | 40628 KB |
1
|
input23 | AC | 28 ms | 40420 KB |
1
|
input24 | AC | 41 ms | 40468 KB |
1
|
input25 | AC | 46 ms | 40516 KB |
1
|
input26 | AC | 24 ms | 40568 KB |
1
|
input27 | AC | 27 ms | 40620 KB |
1
|
input28 | AC | 36 ms | 40540 KB |
1
|
input29 | AC | 34 ms | 40460 KB |
1
|
input30 | AC | 40 ms | 40380 KB |
1
|
input31 | AC | 40 ms | 40428 KB |
1
|
input32 | AC | 43 ms | 40352 KB |
1
|
input33 | AC | 44 ms | 40404 KB |
1
|
input34 | AC | 20 ms | 40456 KB |
1
|
input35 | AC | 24 ms | 40504 KB |
1
|
input36 | AC | 30 ms | 40420 KB |
1
|
input37 | AC | 25 ms | 40336 KB |
1
|
input38 | AC | 25 ms | 40384 KB |
1
|
input39 | AC | 26 ms | 40436 KB |
1
|
input40 | AC | 24 ms | 40480 KB |
1
|
input41 | AC | 40 ms | 40524 KB |
1
|
input42 | AC | 40 ms | 40568 KB |
1
|
input43 | AC | 38 ms | 40616 KB |
1
|
input44 | AC | 27 ms | 40660 KB |
1
|
input45 | AC | 25 ms | 40584 KB |
1
|
input46 | AC | 38 ms | 40504 KB |
1
|
input47 | AC | 35 ms | 40552 KB |
1
|
input48 | AC | 40 ms | 40476 KB |
1
|
input49 | AC | 50 ms | 40524 KB |
1
|
input50 | AC | 24 ms | 40572 KB |
1
|
input51 | AC | 47 ms | 40492 KB |
1
|
input52 | AC | 45 ms | 40540 KB |
1
|
input53 | AC | 44 ms | 40584 KB |
1
|
input54 | AC | 48 ms | 40628 KB |
1
|
input55 | AC | 39 ms | 40680 KB |
1
|
input56 | AC | 40 ms | 40600 KB |
1
|
input57 | AC | 43 ms | 40648 KB |
1
|
input58 | AC | 41 ms | 40568 KB |
1
|
input59 | AC | 44 ms | 40612 KB |
1
|
input60 | AC | 40 ms | 40660 KB |
1
|