# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
432791 | REALITYNB | Holiday (IOI14_holiday) | C++17 | 5086 ms | 5256 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) ;
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) ;
}
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... |