# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
422671 | Andyvanh1 | Holiday (IOI14_holiday) | C++14 | 44 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;
#define vt vector
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,x) for(int (i) = 0; (i) < (x); (i)++ )
typedef long long ll;
typedef long double ld;
typedef vt<int> vi;
typedef pair<int,int> pii;
long long int findMaxAttraction(int n, int start, int d,int attraction[]){
ll Max = 0;
if(d>2*n-1)d = 2*n-1;
multiset<int> st;
ll cur = 0;
int a = d/2+1;
int b = (d+1)/2;
for(int i = 0; i < a; i++){
st.insert(attraction[i]);
cur+=attraction[i];
}
while(st.size()!=b){
cur-=*st.begin();
st.erase(st.begin());
}
Max = cur;
while(a < n&&b!=0){
b--;
cur += attraction[a];
st.insert(attraction[a]);
cur -= *st.begin();
st.erase(st.begin());
cur -= *st.begin();
st.erase(st.begin());
Max = max(Max, cur);
a++;
}
return Max;
}
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... |