Submission #00074


ソースコード

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
#include <bits/stdc++.h>
using namespace std;
int n, m;
int w[555];
int ans[555];
int memo[555][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 (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:25:10
言語 C++11
状態 Wrong Answer
得点 0
ソースコード長 998 Byte
最大実行時間 1000 ms
最大メモリ使用量 1904 KB

セット

セット 得点 Cases
1 ALL 0 / 9 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
2502-in1.txt AC 12 ms 1628 KB
1
2502-in2.txt AC 15 ms 1648 KB
1
2502-in3.txt AC 80 ms 1836 KB
1
2502-in4.txt AC 218 ms 1872 KB
1
2502-in5.txt WA 192 ms 1792 KB
1
2502-in6.txt WA 40 ms 1700 KB
1
2502-in7.txt WA 564 ms 1856 KB
1
2502-in8.txt TLE 1000 ms 1872 KB
1
2502-in9.txt WA 459 ms 1904 KB
1
2502-in10.txt WA 583 ms 1548 KB
1
2502-in11.txt AC 920 ms 1576 KB
1
2502-in12.txt AC 266 ms 1608 KB
1
2502-in13.txt WA 868 ms 1652 KB
1
2502-in14.txt AC 336 ms 1672 KB
1
2502-in15.txt TLE 1000 ms 1712 KB
1
2502-in16.txt AC 599 ms 1744 KB
1
2502-in17.txt WA 17 ms 1792 KB
1
2502-in18.txt TLE 1000 ms 1840 KB
1
2502-in19.txt AC 18 ms 1600 KB
1
2502-in20.txt AC 529 ms 1696 KB
1
2502-in21.txt AC 168 ms 1732 KB
1
2502-in22.txt AC 113 ms 1776 KB
1
2502-in23.txt TLE 1000 ms 1824 KB
1