# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
955265 |
2024-03-30T02:23:49 Z |
yellowtoad |
스트랩 (JOI14_straps) |
C++17 |
|
14 ms |
32348 KB |
#include <iostream>
#include <algorithm>
#define f first
#define s second
using namespace std;
long long n, x, y, dp[2010][2010], maxx;
pair<long long,long long> a[2010];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i].f >> a[i].s;
sort(a+1,a+n+1,greater<pair<long long,long long>>());
dp[0][0] = -1e18;
for (int i = 2; i <= n; i++) dp[0][i] = -1e18;
for (int i = 1; i <= n; i++) {
x = a[i].f; y = a[i].s;
for (int j = 0; j < n; j++) {
dp[i][j] = dp[i-1][j];
if (j-x+1 >= 0) dp[i][j] = max(dp[i][j],dp[i-1][j-x+1]+y);
}
dp[i][n] = dp[i-1][n];
for (int j = n-x+1; j <= n; j++) dp[i][n] = max(dp[i][n],dp[i-1][j]+y);
}
for (int i = 0; i <= n; i++) maxx = max(maxx,dp[n][i]);
cout << maxx << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
2 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2492 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
1 ms |
2488 KB |
Output is correct |
24 |
Correct |
1 ms |
2532 KB |
Output is correct |
25 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
8 ms |
16988 KB |
Output is correct |
9 |
Correct |
5 ms |
16988 KB |
Output is correct |
10 |
Correct |
4 ms |
16988 KB |
Output is correct |
11 |
Correct |
4 ms |
16988 KB |
Output is correct |
12 |
Correct |
11 ms |
32176 KB |
Output is correct |
13 |
Correct |
9 ms |
31836 KB |
Output is correct |
14 |
Correct |
10 ms |
31836 KB |
Output is correct |
15 |
Correct |
9 ms |
31836 KB |
Output is correct |
16 |
Correct |
9 ms |
31836 KB |
Output is correct |
17 |
Correct |
9 ms |
31892 KB |
Output is correct |
18 |
Correct |
9 ms |
31836 KB |
Output is correct |
19 |
Correct |
9 ms |
31940 KB |
Output is correct |
20 |
Correct |
11 ms |
31944 KB |
Output is correct |
21 |
Correct |
9 ms |
31836 KB |
Output is correct |
22 |
Correct |
9 ms |
31836 KB |
Output is correct |
23 |
Correct |
9 ms |
31836 KB |
Output is correct |
24 |
Correct |
10 ms |
31836 KB |
Output is correct |
25 |
Correct |
9 ms |
31944 KB |
Output is correct |
26 |
Correct |
9 ms |
31836 KB |
Output is correct |
27 |
Correct |
9 ms |
31832 KB |
Output is correct |
28 |
Correct |
9 ms |
31836 KB |
Output is correct |
29 |
Correct |
10 ms |
31836 KB |
Output is correct |
30 |
Correct |
11 ms |
31836 KB |
Output is correct |
31 |
Correct |
11 ms |
31836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2496 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
4 ms |
16988 KB |
Output is correct |
10 |
Correct |
4 ms |
16988 KB |
Output is correct |
11 |
Correct |
4 ms |
16988 KB |
Output is correct |
12 |
Correct |
5 ms |
16832 KB |
Output is correct |
13 |
Correct |
4 ms |
16988 KB |
Output is correct |
14 |
Correct |
4 ms |
17004 KB |
Output is correct |
15 |
Correct |
4 ms |
16984 KB |
Output is correct |
16 |
Correct |
4 ms |
16988 KB |
Output is correct |
17 |
Correct |
9 ms |
31836 KB |
Output is correct |
18 |
Correct |
10 ms |
31836 KB |
Output is correct |
19 |
Correct |
9 ms |
31944 KB |
Output is correct |
20 |
Correct |
10 ms |
31836 KB |
Output is correct |
21 |
Correct |
9 ms |
31832 KB |
Output is correct |
22 |
Correct |
10 ms |
31836 KB |
Output is correct |
23 |
Correct |
9 ms |
31836 KB |
Output is correct |
24 |
Correct |
9 ms |
31836 KB |
Output is correct |
25 |
Correct |
9 ms |
31932 KB |
Output is correct |
26 |
Correct |
12 ms |
31836 KB |
Output is correct |
27 |
Correct |
9 ms |
31836 KB |
Output is correct |
28 |
Correct |
9 ms |
31932 KB |
Output is correct |
29 |
Correct |
9 ms |
31836 KB |
Output is correct |
30 |
Correct |
9 ms |
31980 KB |
Output is correct |
31 |
Correct |
9 ms |
31836 KB |
Output is correct |
32 |
Correct |
9 ms |
31880 KB |
Output is correct |
33 |
Correct |
10 ms |
31836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
31836 KB |
Output is correct |
2 |
Correct |
10 ms |
31920 KB |
Output is correct |
3 |
Correct |
9 ms |
31836 KB |
Output is correct |
4 |
Correct |
9 ms |
31836 KB |
Output is correct |
5 |
Correct |
10 ms |
31836 KB |
Output is correct |
6 |
Correct |
9 ms |
31836 KB |
Output is correct |
7 |
Correct |
10 ms |
31832 KB |
Output is correct |
8 |
Correct |
9 ms |
31908 KB |
Output is correct |
9 |
Correct |
9 ms |
31836 KB |
Output is correct |
10 |
Correct |
10 ms |
31836 KB |
Output is correct |
11 |
Correct |
9 ms |
31836 KB |
Output is correct |
12 |
Correct |
9 ms |
31836 KB |
Output is correct |
13 |
Correct |
9 ms |
31916 KB |
Output is correct |
14 |
Correct |
9 ms |
31836 KB |
Output is correct |
15 |
Correct |
11 ms |
31920 KB |
Output is correct |
16 |
Correct |
10 ms |
31836 KB |
Output is correct |
17 |
Correct |
9 ms |
31836 KB |
Output is correct |
18 |
Correct |
9 ms |
31836 KB |
Output is correct |
19 |
Correct |
14 ms |
32348 KB |
Output is correct |
20 |
Correct |
11 ms |
31848 KB |
Output is correct |
21 |
Correct |
11 ms |
32100 KB |
Output is correct |
22 |
Correct |
12 ms |
31920 KB |
Output is correct |
23 |
Correct |
11 ms |
31848 KB |
Output is correct |
24 |
Correct |
11 ms |
31900 KB |
Output is correct |
25 |
Correct |
9 ms |
31980 KB |
Output is correct |