# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
731498 |
2023-04-27T13:34:01 Z |
mohav48173 |
Feast (NOI19_feast) |
C++14 |
|
230 ms |
5056 KB |
#include<bits/stdc++.h>
using namespace std;
int n,k;
long long a[400000];
long long m[400000];
long long mincnt=0;
double score=0;
double get(int ind) {
if(ind<0)return 0;
else return m[ind];
}
void calc(double lam) {
double bestscore=0;
long long bestcnt=0;
double bestnxt=-lam;
long long nxtcnt=0;
for(int i=0;i<n;i++) {
if(bestscore-lam-get(i-1)>bestnxt ||
(bestscore-lam-get(i-1)==bestnxt && nxtcnt>bestcnt)) {
bestnxt=bestscore-get(i-1)-lam;
nxtcnt=bestcnt;
}
if(bestnxt+get(i)>bestscore || (bestnxt+get(i)==bestscore && nxtcnt+1<bestcnt)) {
bestscore=bestnxt+get(i);
bestcnt=nxtcnt+1;
}
}
mincnt=bestcnt;
score=bestscore;
}
int main() {
cin>>n>>k;
for(int i=0;i<n;i++)cin>>a[i];
m[0]=a[0];for(int i=1;i<n;i++)m[i]=m[i-1]+a[i];
double l=0,r=1e16;
while((r-l)>(double)(1e-3)) {
double mid=(l+r)/2.0;
calc(mid);
if(mincnt<=k)r=mid;
else l=mid;
}
calc(r);
cout<<(long long)(round(score+k*r))<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
135 ms |
4804 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
93 ms |
4812 KB |
Output is correct |
2 |
Correct |
111 ms |
4896 KB |
Output is correct |
3 |
Correct |
98 ms |
4864 KB |
Output is correct |
4 |
Incorrect |
86 ms |
4844 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
188 ms |
4884 KB |
Output is correct |
2 |
Correct |
230 ms |
4876 KB |
Output is correct |
3 |
Correct |
182 ms |
5016 KB |
Output is correct |
4 |
Correct |
222 ms |
4876 KB |
Output is correct |
5 |
Correct |
202 ms |
4860 KB |
Output is correct |
6 |
Correct |
188 ms |
4964 KB |
Output is correct |
7 |
Correct |
212 ms |
4964 KB |
Output is correct |
8 |
Correct |
186 ms |
4924 KB |
Output is correct |
9 |
Correct |
199 ms |
5020 KB |
Output is correct |
10 |
Correct |
210 ms |
5056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
2 ms |
340 KB |
Output is correct |
22 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
135 ms |
4804 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |