Submission #00072
ソースコード
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 | #include <bits/stdc++.h> using namespace std; int n, m; int w[555]; int ans[555]; bool flag = false ; typedef struct { int s, l, p; } meldy; meldy a[555]; int dfs( int now, int dust) { int ret = 0; if (now == n || dust == 0) return 0; 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 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]; 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:22:15 |
言語 | C++11 |
状態 | Time Limit Exceeded |
得点 | 0 |
ソースコード長 | 868 Byte |
最大実行時間 | 1000 ms |
最大メモリ使用量 | 612 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 0 / 9 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
2502-in1.txt | AC | 11 ms | 476 KB |
1
|
2502-in2.txt | AC | 14 ms | 580 KB |
1
|
2502-in3.txt | TLE | 1000 ms | 532 KB |
1
|
2502-in4.txt | TLE | 1000 ms | 496 KB |
1
|
2502-in5.txt | TLE | 1000 ms | 468 KB |
1
|
2502-in6.txt | TLE | 1000 ms | 564 KB |
1
|
2502-in7.txt | TLE | 1000 ms | 532 KB |
1
|
2502-in8.txt | TLE | 1000 ms | 488 KB |
1
|
2502-in9.txt | TLE | 1000 ms | 444 KB |
1
|
2502-in10.txt | TLE | 1000 ms | 440 KB |
1
|
2502-in11.txt | TLE | 1000 ms | 532 KB |
1
|
2502-in12.txt | TLE | 1000 ms | 496 KB |
1
|
2502-in13.txt | TLE | 1000 ms | 472 KB |
1
|
2502-in14.txt | TLE | 1000 ms | 548 KB |
1
|
2502-in15.txt | TLE | 1000 ms | 516 KB |
1
|
2502-in16.txt | TLE | 1000 ms | 476 KB |
1
|
2502-in17.txt | TLE | 1000 ms | 440 KB |
1
|
2502-in18.txt | TLE | 1000 ms | 540 KB |
1
|
2502-in19.txt | AC | 13 ms | 488 KB |
1
|
2502-in20.txt | TLE | 1000 ms | 416 KB |
1
|
2502-in21.txt | TLE | 1000 ms | 380 KB |
1
|
2502-in22.txt | TLE | 1000 ms | 612 KB |
1
|
2502-in23.txt | TLE | 1000 ms | 584 KB |
1
|