# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
989368 | 2024-05-28T05:07:28 Z | muhammad | Feast (NOI19_feast) | C++17 | 92 ms | 10532 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long #define pli pair<ll, int> const int mxN=3e5; int n, k; ll a[mxN+1], lb, rb=3e14; pli dp[mxN+1]; pli cdp(ll x) { memset(dp, 0, sizeof(dp)); pli ms{}; for(int i=0; i<n; ++i) { pli cs{dp[i].first-a[i], dp[i].second}; if(cs.first^ms.first?cs.first>ms.first:cs.second<ms.second) ms=cs; pli nd{ms.first-x+a[i+1], ms.second+1}; dp[i+1]=(nd.first^dp[i].first?nd.first>dp[i].first:nd.second<dp[i].second)?nd:dp[i]; } return dp[n]; } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for(int i=0; i<n; ++i) cin >> a[i+1], a[i+1]+=a[i]; while(lb<rb) { ll mb=(lb+rb)/2; if(cdp(mb).second<=k) rb=mb; else lb=mb+1; } pli r=cdp(lb); cout << r.first+k*lb; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 60 ms | 7404 KB | Output is correct |
2 | Correct | 63 ms | 10064 KB | Output is correct |
3 | Correct | 63 ms | 10320 KB | Output is correct |
4 | Correct | 62 ms | 10328 KB | Output is correct |
5 | Correct | 62 ms | 10076 KB | Output is correct |
6 | Correct | 61 ms | 10064 KB | Output is correct |
7 | Correct | 61 ms | 10208 KB | Output is correct |
8 | Correct | 64 ms | 10136 KB | Output is correct |
9 | Correct | 63 ms | 10220 KB | Output is correct |
10 | Correct | 61 ms | 10280 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 7260 KB | Output is correct |
2 | Correct | 47 ms | 8536 KB | Output is correct |
3 | Correct | 47 ms | 8292 KB | Output is correct |
4 | Correct | 50 ms | 8532 KB | Output is correct |
5 | Correct | 62 ms | 10068 KB | Output is correct |
6 | Correct | 49 ms | 8532 KB | Output is correct |
7 | Correct | 53 ms | 8540 KB | Output is correct |
8 | Correct | 62 ms | 10312 KB | Output is correct |
9 | Correct | 60 ms | 9980 KB | Output is correct |
10 | Correct | 52 ms | 8540 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 51 ms | 7248 KB | Output is correct |
2 | Correct | 55 ms | 10304 KB | Output is correct |
3 | Correct | 53 ms | 10332 KB | Output is correct |
4 | Correct | 52 ms | 10324 KB | Output is correct |
5 | Correct | 53 ms | 10340 KB | Output is correct |
6 | Correct | 52 ms | 10320 KB | Output is correct |
7 | Correct | 53 ms | 10320 KB | Output is correct |
8 | Correct | 53 ms | 10324 KB | Output is correct |
9 | Correct | 53 ms | 10532 KB | Output is correct |
10 | Correct | 53 ms | 10360 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4956 KB | Output is correct |
2 | Correct | 6 ms | 5160 KB | Output is correct |
3 | Correct | 6 ms | 4952 KB | Output is correct |
4 | Correct | 6 ms | 4956 KB | Output is correct |
5 | Correct | 7 ms | 4956 KB | Output is correct |
6 | Correct | 6 ms | 4956 KB | Output is correct |
7 | Correct | 7 ms | 5068 KB | Output is correct |
8 | Correct | 7 ms | 4956 KB | Output is correct |
9 | Correct | 6 ms | 5160 KB | Output is correct |
10 | Correct | 7 ms | 4956 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4956 KB | Output is correct |
2 | Correct | 6 ms | 5160 KB | Output is correct |
3 | Correct | 6 ms | 4952 KB | Output is correct |
4 | Correct | 6 ms | 4956 KB | Output is correct |
5 | Correct | 7 ms | 4956 KB | Output is correct |
6 | Correct | 6 ms | 4956 KB | Output is correct |
7 | Correct | 7 ms | 5068 KB | Output is correct |
8 | Correct | 7 ms | 4956 KB | Output is correct |
9 | Correct | 6 ms | 5160 KB | Output is correct |
10 | Correct | 7 ms | 4956 KB | Output is correct |
11 | Correct | 6 ms | 4956 KB | Output is correct |
12 | Correct | 7 ms | 4956 KB | Output is correct |
13 | Correct | 7 ms | 4956 KB | Output is correct |
14 | Correct | 6 ms | 4956 KB | Output is correct |
15 | Correct | 6 ms | 5164 KB | Output is correct |
16 | Correct | 7 ms | 4956 KB | Output is correct |
17 | Correct | 6 ms | 5068 KB | Output is correct |
18 | Correct | 6 ms | 5168 KB | Output is correct |
19 | Correct | 6 ms | 4952 KB | Output is correct |
20 | Correct | 8 ms | 5212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4956 KB | Output is correct |
2 | Correct | 6 ms | 5160 KB | Output is correct |
3 | Correct | 6 ms | 4952 KB | Output is correct |
4 | Correct | 6 ms | 4956 KB | Output is correct |
5 | Correct | 7 ms | 4956 KB | Output is correct |
6 | Correct | 6 ms | 4956 KB | Output is correct |
7 | Correct | 7 ms | 5068 KB | Output is correct |
8 | Correct | 7 ms | 4956 KB | Output is correct |
9 | Correct | 6 ms | 5160 KB | Output is correct |
10 | Correct | 7 ms | 4956 KB | Output is correct |
11 | Correct | 6 ms | 4956 KB | Output is correct |
12 | Correct | 7 ms | 4956 KB | Output is correct |
13 | Correct | 7 ms | 4956 KB | Output is correct |
14 | Correct | 6 ms | 4956 KB | Output is correct |
15 | Correct | 6 ms | 5164 KB | Output is correct |
16 | Correct | 7 ms | 4956 KB | Output is correct |
17 | Correct | 6 ms | 5068 KB | Output is correct |
18 | Correct | 6 ms | 5168 KB | Output is correct |
19 | Correct | 6 ms | 4952 KB | Output is correct |
20 | Correct | 8 ms | 5212 KB | Output is correct |
21 | Correct | 7 ms | 4956 KB | Output is correct |
22 | Correct | 8 ms | 5196 KB | Output is correct |
23 | Correct | 7 ms | 4956 KB | Output is correct |
24 | Correct | 7 ms | 5200 KB | Output is correct |
25 | Correct | 7 ms | 4956 KB | Output is correct |
26 | Correct | 7 ms | 5200 KB | Output is correct |
27 | Correct | 7 ms | 4956 KB | Output is correct |
28 | Correct | 7 ms | 4956 KB | Output is correct |
29 | Correct | 6 ms | 4956 KB | Output is correct |
30 | Correct | 7 ms | 4956 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 60 ms | 7404 KB | Output is correct |
2 | Correct | 63 ms | 10064 KB | Output is correct |
3 | Correct | 63 ms | 10320 KB | Output is correct |
4 | Correct | 62 ms | 10328 KB | Output is correct |
5 | Correct | 62 ms | 10076 KB | Output is correct |
6 | Correct | 61 ms | 10064 KB | Output is correct |
7 | Correct | 61 ms | 10208 KB | Output is correct |
8 | Correct | 64 ms | 10136 KB | Output is correct |
9 | Correct | 63 ms | 10220 KB | Output is correct |
10 | Correct | 61 ms | 10280 KB | Output is correct |
11 | Correct | 43 ms | 7260 KB | Output is correct |
12 | Correct | 47 ms | 8536 KB | Output is correct |
13 | Correct | 47 ms | 8292 KB | Output is correct |
14 | Correct | 50 ms | 8532 KB | Output is correct |
15 | Correct | 62 ms | 10068 KB | Output is correct |
16 | Correct | 49 ms | 8532 KB | Output is correct |
17 | Correct | 53 ms | 8540 KB | Output is correct |
18 | Correct | 62 ms | 10312 KB | Output is correct |
19 | Correct | 60 ms | 9980 KB | Output is correct |
20 | Correct | 52 ms | 8540 KB | Output is correct |
21 | Correct | 51 ms | 7248 KB | Output is correct |
22 | Correct | 55 ms | 10304 KB | Output is correct |
23 | Correct | 53 ms | 10332 KB | Output is correct |
24 | Correct | 52 ms | 10324 KB | Output is correct |
25 | Correct | 53 ms | 10340 KB | Output is correct |
26 | Correct | 52 ms | 10320 KB | Output is correct |
27 | Correct | 53 ms | 10320 KB | Output is correct |
28 | Correct | 53 ms | 10324 KB | Output is correct |
29 | Correct | 53 ms | 10532 KB | Output is correct |
30 | Correct | 53 ms | 10360 KB | Output is correct |
31 | Correct | 6 ms | 4956 KB | Output is correct |
32 | Correct | 6 ms | 5160 KB | Output is correct |
33 | Correct | 6 ms | 4952 KB | Output is correct |
34 | Correct | 6 ms | 4956 KB | Output is correct |
35 | Correct | 7 ms | 4956 KB | Output is correct |
36 | Correct | 6 ms | 4956 KB | Output is correct |
37 | Correct | 7 ms | 5068 KB | Output is correct |
38 | Correct | 7 ms | 4956 KB | Output is correct |
39 | Correct | 6 ms | 5160 KB | Output is correct |
40 | Correct | 7 ms | 4956 KB | Output is correct |
41 | Correct | 6 ms | 4956 KB | Output is correct |
42 | Correct | 7 ms | 4956 KB | Output is correct |
43 | Correct | 7 ms | 4956 KB | Output is correct |
44 | Correct | 6 ms | 4956 KB | Output is correct |
45 | Correct | 6 ms | 5164 KB | Output is correct |
46 | Correct | 7 ms | 4956 KB | Output is correct |
47 | Correct | 6 ms | 5068 KB | Output is correct |
48 | Correct | 6 ms | 5168 KB | Output is correct |
49 | Correct | 6 ms | 4952 KB | Output is correct |
50 | Correct | 8 ms | 5212 KB | Output is correct |
51 | Correct | 7 ms | 4956 KB | Output is correct |
52 | Correct | 8 ms | 5196 KB | Output is correct |
53 | Correct | 7 ms | 4956 KB | Output is correct |
54 | Correct | 7 ms | 5200 KB | Output is correct |
55 | Correct | 7 ms | 4956 KB | Output is correct |
56 | Correct | 7 ms | 5200 KB | Output is correct |
57 | Correct | 7 ms | 4956 KB | Output is correct |
58 | Correct | 7 ms | 4956 KB | Output is correct |
59 | Correct | 6 ms | 4956 KB | Output is correct |
60 | Correct | 7 ms | 4956 KB | Output is correct |
61 | Correct | 83 ms | 10344 KB | Output is correct |
62 | Correct | 92 ms | 10496 KB | Output is correct |
63 | Correct | 61 ms | 10388 KB | Output is correct |
64 | Correct | 83 ms | 10480 KB | Output is correct |
65 | Correct | 76 ms | 10324 KB | Output is correct |
66 | Correct | 74 ms | 10332 KB | Output is correct |
67 | Correct | 73 ms | 10400 KB | Output is correct |
68 | Correct | 53 ms | 10320 KB | Output is correct |
69 | Correct | 54 ms | 10324 KB | Output is correct |
70 | Correct | 52 ms | 10228 KB | Output is correct |