답안 #157225

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
157225 2019-10-10T08:01:11 Z manh9203 스트랩 (JOI14_straps) C++17
95 / 100
245 ms 23644 KB
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#define fi first
#define se second
const int N = 2e3 + 5;
long long n,dp[N][N],rmq[N][20];
pair<long long,long long> rope[N];
long long get(int l,int r){
	int k = log2(r - l + 1);
	return max(rmq[l][k], rmq[r-(1<<k)+1][k]);
}
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;
	sort(rope+1, rope+1+n);
	for(int i=0;i<=n;i++) rmq[i][0] = dp[0][i];
	for(int j=1;(1<<j)<=n;j++){
		for(int i=0;i+(1<<j)-1<=n;j++){
			rmq[i][j] = max(rmq[i][j-1], rmq[i+(1<<(j-1))][j-1]);
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=i;j++){
			dp[i][j] = max(dp[i-1][j], get(j - 1, min(n, j + rope[i].fi - 1)) + rope[i].se);
		}
		for(int j=0;j<=n;j++){
			rmq[j][0] = dp[i][j];
		}
		for(int k=1;(1<<k)<=n;k++){
			for(int j=0;j+(1<<k)-1<=n;j++){
				rmq[j][k] = max(rmq[j][k-1], rmq[j+(1<<(k-1))][k-1]);
			}
		}
	}
	cout << max(dp[n][0], dp[n][1]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 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 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 424 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Incorrect 4 ms 376 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 3 ms 760 KB Output is correct
3 Correct 2 ms 760 KB Output is correct
4 Correct 2 ms 760 KB Output is correct
5 Correct 15 ms 804 KB Output is correct
6 Correct 4 ms 760 KB Output is correct
7 Correct 3 ms 760 KB Output is correct
8 Correct 48 ms 8484 KB Output is correct
9 Correct 51 ms 8440 KB Output is correct
10 Correct 47 ms 8440 KB Output is correct
11 Correct 46 ms 8440 KB Output is correct
12 Correct 219 ms 23496 KB Output is correct
13 Correct 219 ms 23288 KB Output is correct
14 Correct 213 ms 23416 KB Output is correct
15 Correct 213 ms 23364 KB Output is correct
16 Correct 213 ms 23544 KB Output is correct
17 Correct 215 ms 23332 KB Output is correct
18 Correct 213 ms 23452 KB Output is correct
19 Correct 221 ms 23592 KB Output is correct
20 Correct 220 ms 23364 KB Output is correct
21 Correct 213 ms 23352 KB Output is correct
22 Correct 217 ms 23368 KB Output is correct
23 Correct 213 ms 23496 KB Output is correct
24 Correct 209 ms 23340 KB Output is correct
25 Correct 211 ms 23416 KB Output is correct
26 Correct 208 ms 23388 KB Output is correct
27 Correct 217 ms 23288 KB Output is correct
28 Correct 210 ms 23516 KB Output is correct
29 Correct 234 ms 23320 KB Output is correct
30 Correct 234 ms 23520 KB Output is correct
31 Correct 240 ms 23536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 760 KB Output is correct
2 Correct 3 ms 760 KB Output is correct
3 Correct 2 ms 760 KB Output is correct
4 Correct 2 ms 760 KB Output is correct
5 Correct 2 ms 888 KB Output is correct
6 Correct 2 ms 760 KB Output is correct
7 Correct 2 ms 760 KB Output is correct
8 Correct 3 ms 888 KB Output is correct
9 Correct 49 ms 8440 KB Output is correct
10 Correct 47 ms 8440 KB Output is correct
11 Correct 49 ms 8440 KB Output is correct
12 Correct 49 ms 8568 KB Output is correct
13 Correct 46 ms 8440 KB Output is correct
14 Correct 50 ms 8496 KB Output is correct
15 Correct 47 ms 8540 KB Output is correct
16 Correct 46 ms 8440 KB Output is correct
17 Correct 221 ms 23356 KB Output is correct
18 Correct 221 ms 23320 KB Output is correct
19 Correct 224 ms 23416 KB Output is correct
20 Correct 214 ms 23336 KB Output is correct
21 Correct 211 ms 23288 KB Output is correct
22 Correct 215 ms 23288 KB Output is correct
23 Correct 211 ms 23416 KB Output is correct
24 Correct 216 ms 23416 KB Output is correct
25 Correct 214 ms 23432 KB Output is correct
26 Correct 218 ms 23516 KB Output is correct
27 Correct 211 ms 23416 KB Output is correct
28 Correct 209 ms 23496 KB Output is correct
29 Correct 214 ms 23368 KB Output is correct
30 Correct 210 ms 23336 KB Output is correct
31 Correct 208 ms 23288 KB Output is correct
32 Correct 208 ms 23464 KB Output is correct
33 Correct 215 ms 23644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 208 ms 23288 KB Output is correct
2 Correct 214 ms 23408 KB Output is correct
3 Correct 220 ms 23288 KB Output is correct
4 Correct 208 ms 23512 KB Output is correct
5 Correct 210 ms 23288 KB Output is correct
6 Correct 210 ms 23304 KB Output is correct
7 Correct 211 ms 23480 KB Output is correct
8 Correct 208 ms 23368 KB Output is correct
9 Correct 210 ms 23388 KB Output is correct
10 Correct 211 ms 23288 KB Output is correct
11 Correct 211 ms 23456 KB Output is correct
12 Correct 212 ms 23448 KB Output is correct
13 Correct 213 ms 23440 KB Output is correct
14 Correct 217 ms 23408 KB Output is correct
15 Correct 213 ms 23392 KB Output is correct
16 Correct 210 ms 23448 KB Output is correct
17 Correct 212 ms 23352 KB Output is correct
18 Correct 215 ms 23472 KB Output is correct
19 Correct 239 ms 23360 KB Output is correct
20 Correct 234 ms 23288 KB Output is correct
21 Correct 245 ms 23416 KB Output is correct
22 Correct 240 ms 23352 KB Output is correct
23 Correct 236 ms 23416 KB Output is correct
24 Correct 238 ms 23480 KB Output is correct
25 Correct 210 ms 23416 KB Output is correct