This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include"holiday.h"
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define N 100005
long long sum,ans;
priority_queue<long long,vector<long long>,greater<long long>> q;
void add(long long x){
q.push(x);
sum+=x;
}
void upd(int k){
while(!q.empty()&&q.size()>k){
sum-=q.top();
q.pop();
}
}
long long int findMaxAttraction(int n,int st,int d,int a[]){
int i,j;
if(n<=3000){
for(i=0;i<=st;i++){
sum=0;
for(j=i;j<st;j++)add(a[j]);
for(j=st;j<n;j++){
add(a[j]);
upd(d-j+i-min(st-i,j-st));
ans=max(ans,sum);
}
}
}
else if(st==0){
sum=0;
for(i=0;i<n;i++){
add(a[i]);
upd(d-i);
ans=max(ans,sum);
}
}
return ans;
}
Compilation message (stderr)
holiday.cpp: In function 'void upd(int)':
holiday.cpp:17:31: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
17 | while(!q.empty()&&q.size()>k){
| ~~~~~~~~^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |