-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ_14501.cpp
More file actions
46 lines (41 loc) · 746 Bytes
/
BOJ_14501.cpp
File metadata and controls
46 lines (41 loc) · 746 Bytes
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
#include <bits/stdc++.h>
using namespace std;
int calc(int T[], int P[], int N){
int day[N+1];
for (int i = 0; i <= N; i++){
day[i] = i+1;
}
int max[N+1];
for (int a = 0; a <= N; a++){
max[a] = 0;
}
for (int i = 0; i <= N; i++){
for (int j = 0; j < i; j++){
if (day[j] + T[j] == day[i]){
if (max[i] < (max[j] + P[j])){
fill(max+i, max + N + 1, max[j] + P[j]);
}
}
}
}
int temp = 0;
for (int a = 0; a < N + 1; a++){
if (temp < max[a]){
temp = max[a];
}
}
return temp;
}
int main(){
int N;
cin >> N;
int T[N+1];
int P[N+1];
for (int i = 0; i < N; i++){
cin >> T[i];
cin >> P[i];
}
T[N] = 0;
P[N] = 0;
cout << calc(T, P, N);
}