# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
432787 | REALITYNB | Holiday (IOI14_holiday) | C++17 | 5054 ms | 6212 KiB |
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;
long long findMaxAttraction(int n , int start , int d , int* a){
#define int long long
int ans = 0 ;
for(int i=start;i<n;i++){
multiset<int> el ;
for(int j=start;j<=i;j++) el.insert(a[j]) ;
int sum = 0;
int rest = d-(i-start+1) ;
if(rest<0) break ;
while(el.size()>rest)
el.erase(el.begin());
for(int x: el) sum+=x ;
ans=max(ans,sum) ;
// cout << i << " "<< sum << endl ;
for(int j=start-1;j>-1;--j){
rest = d-(min(start-j,i-start)*2+max(start-j,i-start));
//cout << i << " "<< j << " "<< rest << endl ;
if(rest<0) break ;
el.insert(a[j]) ;
sum+=a[j] ;
while(el.size()>rest){
sum-=*el.begin();
el.erase(el.begin()) ;
}
//cout << i << " "<< j << " "<< rest << " " << sum << endl ;
ans=max(ans,sum) ;
}
}
return ans ;
#undef int
}
/*int main(){
int a[5]= {10,2,20,30,1} ;
cout << findMaxAttraction(5,2,7,a) ;
return 0 ;
}
*/
Compilation message (stderr)
# | 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... |