Submission #65751
ソースコード
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 49 50 | #include <bits/stdc++.h> #define lol long long #define gcd(x, y) __gcd(x, y) #define mt make_tuple #define mp make_pair #define fi first #define se second #define fixed(x) fixed << setprecision(x) using namespace std; using pii = pair< int , int >; 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 ); } template < class A> inline A abs (A& a) { return (a < 0 ? -a : a); } bool inLine( int x, int y, int mx, int my) { return (x >= 0 && y >= 0 && x < mx && y < my); } const lol inf = (1LL << 62); const int MOD = (1e9) + 7; const int mod = 998244353; const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1, -2, -2, -2, -2, -2, -1, -1, 1, 1, 0, 0, 2, 2, 2, 2, 2}; const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1, -2, -1, 0, 1, 2, -2, 2, -2, 2, -2, 2, -2, -1, 0, 1, 2}; signed main() { cin.tie(0); ios::sync_with_stdio( false ); int n,w; cin >>n>>w; vector< int > ans(w+10,0); for ( int i=0;i<n;i++){ int v,p; cin >>v>>p; for ( int j=p;j<=w;j++){ chmax(ans[j],ans[j-p]+v); } } cout <<ans[w]<< '\n' ; return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 0239 - ナップザック問題(Medium) |
ユーザー名 | ei1923 |
投稿日時 | 2021-02-05 17:55:31 |
言語 | C++17 |
状態 | Accepted |
得点 | 3 |
ソースコード長 | 1266 Byte |
最大実行時間 | 58 ms |
最大メモリ使用量 | 936 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 3 / 3 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
DPL_1_C_in1.txt | AC | 58 ms | 604 KB |
1
|
DPL_1_C_in2.txt | AC | 22 ms | 584 KB |
1
|
DPL_1_C_in3.txt | AC | 32 ms | 712 KB |
1
|
DPL_1_C_in4.txt | AC | 27 ms | 820 KB |
1
|
DPL_1_C_in5.txt | AC | 18 ms | 816 KB |
1
|
DPL_1_C_in6.txt | AC | 19 ms | 772 KB |
1
|
DPL_1_C_in7.txt | AC | 26 ms | 856 KB |
1
|
DPL_1_C_in8.txt | AC | 23 ms | 812 KB |
1
|
DPL_1_C_in9.txt | AC | 16 ms | 768 KB |
1
|
DPL_1_C_in10.txt | AC | 26 ms | 428 KB |
1
|
DPL_1_C_in11.txt | AC | 28 ms | 380 KB |
1
|
DPL_1_C_in12.txt | AC | 25 ms | 464 KB |
1
|
DPL_1_C_in13.txt | AC | 24 ms | 548 KB |
1
|
DPL_1_C_in14.txt | AC | 21 ms | 624 KB |
1
|
DPL_1_C_in15.txt | AC | 25 ms | 568 KB |
1
|
DPL_1_C_in16.txt | AC | 23 ms | 628 KB |
1
|
DPL_1_C_in17.txt | AC | 24 ms | 680 KB |
1
|
DPL_1_C_in18.txt | AC | 28 ms | 720 KB |
1
|
DPL_1_C_in19.txt | AC | 17 ms | 668 KB |
1
|
DPL_1_C_in20.txt | AC | 23 ms | 536 KB |
1
|
DPL_1_C_in21.txt | AC | 16 ms | 624 KB |
1
|
DPL_1_C_in22.txt | AC | 24 ms | 580 KB |
1
|
DPL_1_C_in23.txt | AC | 21 ms | 656 KB |
1
|
DPL_1_C_in24.txt | AC | 19 ms | 720 KB |
1
|
DPL_1_C_in25.txt | AC | 26 ms | 768 KB |
1
|
DPL_1_C_in26.txt | AC | 20 ms | 688 KB |
1
|
DPL_1_C_in27.txt | AC | 26 ms | 728 KB |
1
|
DPL_1_C_in28.txt | AC | 21 ms | 808 KB |
1
|
DPL_1_C_in29.txt | AC | 19 ms | 756 KB |
1
|
DPL_1_C_in30.txt | AC | 28 ms | 792 KB |
1
|
DPL_1_C_in31.txt | AC | 18 ms | 748 KB |
1
|
DPL_1_C_in32.txt | AC | 24 ms | 692 KB |
1
|
DPL_1_C_in33.txt | AC | 20 ms | 888 KB |
1
|
DPL_1_C_in34.txt | AC | 22 ms | 936 KB |
1
|
DPL_1_C_in35.txt | AC | 22 ms | 856 KB |
1
|
DPL_1_C_in36.txt | AC | 21 ms | 900 KB |
1
|
DPL_1_C_in37.txt | AC | 22 ms | 812 KB |
1
|
DPL_1_C_in38.txt | AC | 21 ms | 860 KB |
1
|
DPL_1_C_in39.txt | AC | 21 ms | 776 KB |
1
|
DPL_1_C_in40.txt | AC | 22 ms | 904 KB |
1
|