# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
298965 | abyyskit | Holiday (IOI14_holiday) | C++14 | 5064 ms | 6444 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"holiday.h"
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, x, y) for(int i = x; i < y; ++i)
long long Rightsolve(int d, vector<int> & A, int start){
if (d <= 0){
return 0;
}
multiset<int> s;
long long ans = 0;
long long mans = 0;
FOR(i, start, A.size()){
s.insert(A[i]);
ans += (long long)A[i];
int travel = i - start;
while(s.size() != 0 && travel + s.size() > d){
ans -= *s.begin();
s.erase(s.begin());
}
mans = max(ans, mans);
}
return mans;
}
long long int findMaxAttraction(int n, int start, int d, int attraction[]) {
vector<int> T(n);
vector<int> R(n);
FOR(i, 0, n){
T[i] = attraction[i];
R[n - i -1] = attraction[i];
}
long long ans = 0;
FOR(i, 0, start + 1){
ans = max(ans, Rightsolve(d- (start - i), T, i));
}
if (start != 0){
FOR(i, start, n){
ans = max(ans, Rightsolve(d - (i - start), R, n - i - 1));
}
}
return ans;
}
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... |