# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1026005 |
2024-07-17T12:28:51 Z |
ach00 |
Feast (NOI19_feast) |
C++14 |
|
747 ms |
27372 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define MP make_pair
#define EPS 0.00001
int n,k;
vector<ll> W;
pair<ll,ll> solve(ll pen) {
vector<vector<pair<ll,ll>>> dp(300005, vector<pair<ll,ll>>(2));
dp[0][0] = {0, 0};
dp[0][1] = {W[0] - pen, 1};
for(int i = 1; i < n; i++) {
dp[i][0] = max(dp[i-1][0], dp[i-1][1]);
dp[i][1] = max(MP(dp[i-1][1].first + W[i], dp[i-1][1].second), MP(dp[i-1][0].first + W[i] - pen, dp[i-1][0].second + 1));
}
return max(dp[n-1][0], dp[n-1][1]);
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> k;
ll lower = 0;
ll upper = 10000000000000;
W.resize(n); for(auto &a : W) cin >> a;
while(lower < upper) {
ll m = (lower+upper+1)/2;
auto K = solve(m);
if(K.second >= k) {
lower = m;
} else {
upper = m-1;
}
}
auto K = solve(lower);
cout << K.first + k*lower;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
660 ms |
26240 KB |
Output is correct |
2 |
Correct |
600 ms |
26508 KB |
Output is correct |
3 |
Correct |
613 ms |
26576 KB |
Output is correct |
4 |
Correct |
659 ms |
26596 KB |
Output is correct |
5 |
Correct |
662 ms |
26520 KB |
Output is correct |
6 |
Correct |
608 ms |
26736 KB |
Output is correct |
7 |
Correct |
596 ms |
26720 KB |
Output is correct |
8 |
Correct |
613 ms |
26868 KB |
Output is correct |
9 |
Correct |
603 ms |
26736 KB |
Output is correct |
10 |
Correct |
634 ms |
26796 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
600 ms |
25064 KB |
Output is correct |
2 |
Correct |
606 ms |
25108 KB |
Output is correct |
3 |
Correct |
589 ms |
25292 KB |
Output is correct |
4 |
Correct |
592 ms |
25088 KB |
Output is correct |
5 |
Correct |
610 ms |
26716 KB |
Output is correct |
6 |
Correct |
596 ms |
25120 KB |
Output is correct |
7 |
Correct |
601 ms |
25132 KB |
Output is correct |
8 |
Correct |
627 ms |
26924 KB |
Output is correct |
9 |
Correct |
635 ms |
26796 KB |
Output is correct |
10 |
Correct |
621 ms |
25140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
657 ms |
26992 KB |
Output is correct |
2 |
Correct |
650 ms |
27372 KB |
Output is correct |
3 |
Correct |
672 ms |
27084 KB |
Output is correct |
4 |
Correct |
638 ms |
26936 KB |
Output is correct |
5 |
Correct |
616 ms |
26992 KB |
Output is correct |
6 |
Correct |
623 ms |
27004 KB |
Output is correct |
7 |
Correct |
665 ms |
27016 KB |
Output is correct |
8 |
Correct |
676 ms |
26988 KB |
Output is correct |
9 |
Correct |
654 ms |
27060 KB |
Output is correct |
10 |
Correct |
681 ms |
27088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
668 ms |
21740 KB |
Output is correct |
2 |
Correct |
610 ms |
21648 KB |
Output is correct |
3 |
Correct |
644 ms |
21684 KB |
Output is correct |
4 |
Correct |
575 ms |
21648 KB |
Output is correct |
5 |
Correct |
616 ms |
21656 KB |
Output is correct |
6 |
Correct |
607 ms |
21636 KB |
Output is correct |
7 |
Correct |
567 ms |
21648 KB |
Output is correct |
8 |
Correct |
569 ms |
21620 KB |
Output is correct |
9 |
Correct |
558 ms |
21672 KB |
Output is correct |
10 |
Correct |
600 ms |
21696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
668 ms |
21740 KB |
Output is correct |
2 |
Correct |
610 ms |
21648 KB |
Output is correct |
3 |
Correct |
644 ms |
21684 KB |
Output is correct |
4 |
Correct |
575 ms |
21648 KB |
Output is correct |
5 |
Correct |
616 ms |
21656 KB |
Output is correct |
6 |
Correct |
607 ms |
21636 KB |
Output is correct |
7 |
Correct |
567 ms |
21648 KB |
Output is correct |
8 |
Correct |
569 ms |
21620 KB |
Output is correct |
9 |
Correct |
558 ms |
21672 KB |
Output is correct |
10 |
Correct |
600 ms |
21696 KB |
Output is correct |
11 |
Correct |
598 ms |
21676 KB |
Output is correct |
12 |
Correct |
541 ms |
21636 KB |
Output is correct |
13 |
Correct |
548 ms |
21640 KB |
Output is correct |
14 |
Correct |
524 ms |
21632 KB |
Output is correct |
15 |
Correct |
527 ms |
21640 KB |
Output is correct |
16 |
Correct |
566 ms |
21604 KB |
Output is correct |
17 |
Correct |
541 ms |
21688 KB |
Output is correct |
18 |
Correct |
539 ms |
21664 KB |
Output is correct |
19 |
Correct |
528 ms |
21672 KB |
Output is correct |
20 |
Correct |
560 ms |
21640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
668 ms |
21740 KB |
Output is correct |
2 |
Correct |
610 ms |
21648 KB |
Output is correct |
3 |
Correct |
644 ms |
21684 KB |
Output is correct |
4 |
Correct |
575 ms |
21648 KB |
Output is correct |
5 |
Correct |
616 ms |
21656 KB |
Output is correct |
6 |
Correct |
607 ms |
21636 KB |
Output is correct |
7 |
Correct |
567 ms |
21648 KB |
Output is correct |
8 |
Correct |
569 ms |
21620 KB |
Output is correct |
9 |
Correct |
558 ms |
21672 KB |
Output is correct |
10 |
Correct |
600 ms |
21696 KB |
Output is correct |
11 |
Correct |
598 ms |
21676 KB |
Output is correct |
12 |
Correct |
541 ms |
21636 KB |
Output is correct |
13 |
Correct |
548 ms |
21640 KB |
Output is correct |
14 |
Correct |
524 ms |
21632 KB |
Output is correct |
15 |
Correct |
527 ms |
21640 KB |
Output is correct |
16 |
Correct |
566 ms |
21604 KB |
Output is correct |
17 |
Correct |
541 ms |
21688 KB |
Output is correct |
18 |
Correct |
539 ms |
21664 KB |
Output is correct |
19 |
Correct |
528 ms |
21672 KB |
Output is correct |
20 |
Correct |
560 ms |
21640 KB |
Output is correct |
21 |
Correct |
567 ms |
21880 KB |
Output is correct |
22 |
Correct |
564 ms |
21760 KB |
Output is correct |
23 |
Correct |
573 ms |
21632 KB |
Output is correct |
24 |
Correct |
615 ms |
21924 KB |
Output is correct |
25 |
Correct |
536 ms |
21640 KB |
Output is correct |
26 |
Correct |
547 ms |
21656 KB |
Output is correct |
27 |
Correct |
523 ms |
21640 KB |
Output is correct |
28 |
Correct |
540 ms |
21672 KB |
Output is correct |
29 |
Correct |
529 ms |
21680 KB |
Output is correct |
30 |
Correct |
522 ms |
21648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
660 ms |
26240 KB |
Output is correct |
2 |
Correct |
600 ms |
26508 KB |
Output is correct |
3 |
Correct |
613 ms |
26576 KB |
Output is correct |
4 |
Correct |
659 ms |
26596 KB |
Output is correct |
5 |
Correct |
662 ms |
26520 KB |
Output is correct |
6 |
Correct |
608 ms |
26736 KB |
Output is correct |
7 |
Correct |
596 ms |
26720 KB |
Output is correct |
8 |
Correct |
613 ms |
26868 KB |
Output is correct |
9 |
Correct |
603 ms |
26736 KB |
Output is correct |
10 |
Correct |
634 ms |
26796 KB |
Output is correct |
11 |
Correct |
600 ms |
25064 KB |
Output is correct |
12 |
Correct |
606 ms |
25108 KB |
Output is correct |
13 |
Correct |
589 ms |
25292 KB |
Output is correct |
14 |
Correct |
592 ms |
25088 KB |
Output is correct |
15 |
Correct |
610 ms |
26716 KB |
Output is correct |
16 |
Correct |
596 ms |
25120 KB |
Output is correct |
17 |
Correct |
601 ms |
25132 KB |
Output is correct |
18 |
Correct |
627 ms |
26924 KB |
Output is correct |
19 |
Correct |
635 ms |
26796 KB |
Output is correct |
20 |
Correct |
621 ms |
25140 KB |
Output is correct |
21 |
Correct |
657 ms |
26992 KB |
Output is correct |
22 |
Correct |
650 ms |
27372 KB |
Output is correct |
23 |
Correct |
672 ms |
27084 KB |
Output is correct |
24 |
Correct |
638 ms |
26936 KB |
Output is correct |
25 |
Correct |
616 ms |
26992 KB |
Output is correct |
26 |
Correct |
623 ms |
27004 KB |
Output is correct |
27 |
Correct |
665 ms |
27016 KB |
Output is correct |
28 |
Correct |
676 ms |
26988 KB |
Output is correct |
29 |
Correct |
654 ms |
27060 KB |
Output is correct |
30 |
Correct |
681 ms |
27088 KB |
Output is correct |
31 |
Correct |
668 ms |
21740 KB |
Output is correct |
32 |
Correct |
610 ms |
21648 KB |
Output is correct |
33 |
Correct |
644 ms |
21684 KB |
Output is correct |
34 |
Correct |
575 ms |
21648 KB |
Output is correct |
35 |
Correct |
616 ms |
21656 KB |
Output is correct |
36 |
Correct |
607 ms |
21636 KB |
Output is correct |
37 |
Correct |
567 ms |
21648 KB |
Output is correct |
38 |
Correct |
569 ms |
21620 KB |
Output is correct |
39 |
Correct |
558 ms |
21672 KB |
Output is correct |
40 |
Correct |
600 ms |
21696 KB |
Output is correct |
41 |
Correct |
598 ms |
21676 KB |
Output is correct |
42 |
Correct |
541 ms |
21636 KB |
Output is correct |
43 |
Correct |
548 ms |
21640 KB |
Output is correct |
44 |
Correct |
524 ms |
21632 KB |
Output is correct |
45 |
Correct |
527 ms |
21640 KB |
Output is correct |
46 |
Correct |
566 ms |
21604 KB |
Output is correct |
47 |
Correct |
541 ms |
21688 KB |
Output is correct |
48 |
Correct |
539 ms |
21664 KB |
Output is correct |
49 |
Correct |
528 ms |
21672 KB |
Output is correct |
50 |
Correct |
560 ms |
21640 KB |
Output is correct |
51 |
Correct |
567 ms |
21880 KB |
Output is correct |
52 |
Correct |
564 ms |
21760 KB |
Output is correct |
53 |
Correct |
573 ms |
21632 KB |
Output is correct |
54 |
Correct |
615 ms |
21924 KB |
Output is correct |
55 |
Correct |
536 ms |
21640 KB |
Output is correct |
56 |
Correct |
547 ms |
21656 KB |
Output is correct |
57 |
Correct |
523 ms |
21640 KB |
Output is correct |
58 |
Correct |
540 ms |
21672 KB |
Output is correct |
59 |
Correct |
529 ms |
21680 KB |
Output is correct |
60 |
Correct |
522 ms |
21648 KB |
Output is correct |
61 |
Correct |
650 ms |
23940 KB |
Output is correct |
62 |
Correct |
628 ms |
23992 KB |
Output is correct |
63 |
Correct |
640 ms |
23904 KB |
Output is correct |
64 |
Correct |
648 ms |
23976 KB |
Output is correct |
65 |
Correct |
735 ms |
24068 KB |
Output is correct |
66 |
Correct |
747 ms |
24096 KB |
Output is correct |
67 |
Correct |
716 ms |
23940 KB |
Output is correct |
68 |
Correct |
613 ms |
23980 KB |
Output is correct |
69 |
Correct |
607 ms |
24076 KB |
Output is correct |
70 |
Correct |
623 ms |
24188 KB |
Output is correct |