Submission #00091
ソースコード
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 51 52 53 54 55 56 | #include <bits/stdc++.h> using namespace std; int n, m; int w[400]; int ans[400]; int memo[400][400]; bool flag = false ; typedef struct { int s, l, p; } meldy; meldy a[400]; int dfs( int now, int dust) { int ret = 0; if (dust == 0) return 0; if (now == n) return -1000000; if (memo[now][dust] != -1) return memo[now][dust]; if (dust - a[now].s >= 0) { for ( int i = a[now].s; i <= a[now].l; i++) { if (dust - i < 0) break ; ret = max(ret, dfs(now+1, dust-i) + a[now].p); } } return memo[now][dust] = max(ret, dfs(now+1, dust)); } int main() { cin >> n; for ( int i = 0; i < n; i++) { cin >> a[i].s >> a[i].l >> a[i].p; } cin >> m; for ( int i = 0; i < m; i++) { cin >> w[i]; memset (memo, -1, sizeof (memo)); ans[i] = dfs(0, w[i]); if (ans[i] == 0) flag = true ; } if (flag == true ) cout << "-1" << endl; else { for ( int i = 0; i < m; i++) { cout << ans[i] << endl; } } } |
ステータス
項目 | データ |
---|---|
問題 | 0004 - VOCAL ANDROID |
ユーザー名 | udonkun |
投稿日時 | 2016-08-12 11:41:49 |
言語 | C++11 |
状態 | Wrong Answer |
得点 | 0 |
ソースコード長 | 1023 Byte |
最大実行時間 | 1000 ms |
最大メモリ使用量 | 1292 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 0 / 9 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
2502-in1.txt | AC | 11 ms | 1116 KB |
1
|
2502-in2.txt | AC | 14 ms | 1072 KB |
1
|
2502-in3.txt | AC | 78 ms | 1196 KB |
1
|
2502-in4.txt | AC | 214 ms | 1176 KB |
1
|
2502-in5.txt | WA | 188 ms | 1284 KB |
1
|
2502-in6.txt | WA | 41 ms | 1256 KB |
1
|
2502-in7.txt | WA | 561 ms | 1228 KB |
1
|
2502-in8.txt | TLE | 1000 ms | 1184 KB |
1
|
2502-in9.txt | WA | 457 ms | 1156 KB |
1
|
2502-in10.txt | WA | 577 ms | 1096 KB |
1
|
2502-in11.txt | AC | 910 ms | 1188 KB |
1
|
2502-in12.txt | AC | 258 ms | 1292 KB |
1
|
2502-in13.txt | WA | 898 ms | 1144 KB |
1
|
2502-in14.txt | AC | 335 ms | 1104 KB |
1
|
2502-in15.txt | TLE | 1000 ms | 1204 KB |
1
|
2502-in16.txt | AC | 594 ms | 1176 KB |
1
|
2502-in17.txt | WA | 17 ms | 1276 KB |
1
|
2502-in18.txt | TLE | 1000 ms | 1260 KB |
1
|
2502-in19.txt | AC | 17 ms | 1216 KB |
1
|
2502-in20.txt | AC | 522 ms | 1188 KB |
1
|
2502-in21.txt | AC | 164 ms | 1036 KB |
1
|
2502-in22.txt | AC | 111 ms | 1140 KB |
1
|
2502-in23.txt | TLE | 1000 ms | 1248 KB |
1
|