# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
837871 |
2023-08-25T19:18:54 Z |
Ahmed57 |
Feast (NOI19_feast) |
C++17 |
|
689 ms |
18508 KB |
#include<bits/stdc++.h>
using namespace std;
long long n,k;
long long arr[300001];
pair<long long,long long> check(int x){
priority_queue<pair<long long,long long>> q;
q.push({0,0});
pair<long long,long long> ans = {0,0};
for(int i = 0;i<n;i++){
long long val = arr[i]+q.top().first-x;
long long sec = (q.top().second)+1;
pair<long long,long long> fawzya = {val,sec};
ans = max(ans,fawzya);
fawzya = ans;
q.push({(-arr[i])+fawzya.first,fawzya.second});
ans = max(ans,make_pair(fawzya.first,fawzya.second));
}
return ans;
}
int main(){
cin>>n>>k;
for(int i = 0;i<n;i++){
cin>>arr[i];
if(i)arr[i]+=arr[i-1];
}
long long l = 0 , r = 1e12 , ans = 0;
while(l<=r){
long long mid = (l+r)/2;
pair<long long ,long long> an = check(mid);
if(an.second>=k){
ans =an.first+k*mid;
l = mid+1;
}else {
r = mid-1;
}
}
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
527 ms |
18164 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
369 ms |
16612 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
689 ms |
18508 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
527 ms |
18164 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |