Submission #157219

# Submission time Handle Problem Language Result Execution time Memory
157219 2019-10-10T07:04:01 Z manh9203 스트랩 (JOI14_straps) C++17
45 / 100
39 ms 31824 KB
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
const int N = 2e3 + 5;
long long n,dp[N][N];
pair<long long,long long> rope[N];
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i=1;i<=n;i++) cin >> rope[i].fi >> rope[i].se;
	for(int i=0;i<=n;i++){
		for(int j=1;j<=n;j++){
			dp[i][j] = -1e18;
		}
	}
	sort(rope+1, rope+1+n);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=i;j++){
			dp[i][j] = max(dp[i-1][min(n, j + rope[i].fi - 1)], dp[i-1][j-1]) + rope[i].se;
			dp[i][j] = max(dp[i][j], dp[i-1][j]);
		}
	}
	cout << max(dp[n][0], dp[n][1]);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 424 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Incorrect 2 ms 376 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 2 ms 760 KB Output is correct
4 Correct 2 ms 764 KB Output is correct
5 Correct 2 ms 892 KB Output is correct
6 Correct 3 ms 888 KB Output is correct
7 Correct 3 ms 888 KB Output is correct
8 Correct 14 ms 12152 KB Output is correct
9 Correct 16 ms 12280 KB Output is correct
10 Correct 17 ms 12152 KB Output is correct
11 Correct 13 ms 12156 KB Output is correct
12 Correct 39 ms 31736 KB Output is correct
13 Correct 33 ms 31736 KB Output is correct
14 Correct 33 ms 31736 KB Output is correct
15 Correct 33 ms 31736 KB Output is correct
16 Correct 33 ms 31736 KB Output is correct
17 Correct 34 ms 31736 KB Output is correct
18 Correct 33 ms 31736 KB Output is correct
19 Correct 33 ms 31736 KB Output is correct
20 Correct 33 ms 31736 KB Output is correct
21 Correct 33 ms 31736 KB Output is correct
22 Correct 33 ms 31736 KB Output is correct
23 Correct 33 ms 31736 KB Output is correct
24 Correct 34 ms 31736 KB Output is correct
25 Incorrect 38 ms 31804 KB Output isn't correct
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 760 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 2 ms 760 KB Output is correct
4 Correct 2 ms 764 KB Output is correct
5 Correct 2 ms 760 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 3 ms 760 KB Output is correct
8 Correct 3 ms 760 KB Output is correct
9 Correct 13 ms 12152 KB Output is correct
10 Correct 13 ms 12188 KB Output is correct
11 Correct 13 ms 12280 KB Output is correct
12 Correct 14 ms 12152 KB Output is correct
13 Correct 13 ms 12280 KB Output is correct
14 Correct 13 ms 12280 KB Output is correct
15 Correct 13 ms 12280 KB Output is correct
16 Correct 13 ms 12152 KB Output is correct
17 Correct 33 ms 31736 KB Output is correct
18 Correct 33 ms 31740 KB Output is correct
19 Correct 33 ms 31736 KB Output is correct
20 Correct 33 ms 31736 KB Output is correct
21 Correct 33 ms 31820 KB Output is correct
22 Correct 33 ms 31736 KB Output is correct
23 Correct 33 ms 31736 KB Output is correct
24 Correct 33 ms 31736 KB Output is correct
25 Correct 33 ms 31736 KB Output is correct
26 Correct 33 ms 31736 KB Output is correct
27 Correct 34 ms 31736 KB Output is correct
28 Correct 33 ms 31736 KB Output is correct
29 Correct 33 ms 31736 KB Output is correct
30 Correct 33 ms 31824 KB Output is correct
31 Correct 33 ms 31736 KB Output is correct
32 Correct 33 ms 31736 KB Output is correct
33 Correct 33 ms 31736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 31792 KB Output is correct
2 Correct 33 ms 31736 KB Output is correct
3 Correct 33 ms 31740 KB Output is correct
4 Correct 33 ms 31736 KB Output is correct
5 Correct 34 ms 31736 KB Output is correct
6 Incorrect 34 ms 31736 KB Output isn't correct
7 Halted 0 ms 0 KB -