-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP1717.cpp
54 lines (50 loc) · 1.31 KB
/
P1717.cpp
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
#include <cstdio>
#include <queue>
#include <cstdlib>
struct lake {
int fishNum;
int dec;
int timeCost = 0;
};
bool operator<(struct lake lake1, struct lake lake2) {
return lake1.fishNum < lake2.fishNum;
}
#define PQ std::priority_queue<struct lake>
int main() {
int n, time;
scanf("%d", &n); scanf("%d", &time); time *= 12;
struct lake * lakes = (struct lake *) malloc(sizeof(struct lake) * n);
// PQ queue;
for (int i = 0; i < n; i++) {
scanf("%d", &lakes[i].fishNum);
}
for (int i = 0; i < n; i++) {
scanf("%d", &lakes[i].dec);
}
for (int i = 1; i < n; i++) {
scanf("%d", &lakes[i].timeCost);
}
int ans = 0;
for (int i = 1; i <= n; i++) {
PQ lakeQueue;
int timeAvailable = time;
for (int j = 0; j < i; j++) {
lakeQueue.push(lakes[j]);
timeAvailable -= lakes[j].timeCost;
}
int ans2 = 0;
for (int j = timeAvailable; j > 0; j--) {
lake top = lakeQueue.top(); lakeQueue.pop();
if (top.fishNum <= 0) {
break;
}
ans2 += top.fishNum;
top.fishNum -= top.dec;
lakeQueue.push(top);
}
ans = ans2 > ans ? ans2 : ans;
}
free(lakes);
printf("%d\n", ans);
return 0;
}