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"
#define ll long long
#define fi first
#define se second
using namespace std;
int n,x,d,val[100005];
ll solve() {
set <pair<int,int> > s;
ll eaten = 0,ans = val[x];
int left = 0;
eaten = val[x];
s.insert({val[x],x});
for (int i = x + 1; i < n; i++) {
int stamina = i + s.size();
if (i >= d) {left = i + 1; break;}
while (stamina >= d) {
eaten -= (*s.begin()).fi;
s.erase(s.begin());
stamina--;
}
if (stamina < d) {
eaten += val[i];
s.insert({val[i],i});
}
ans = max(ans,eaten);
}
return ans;/*
for (int i = 0;)
for (int i = x + 1; i > 0; i--) {
} */
}
long long int findMaxAttraction(int n1, int start, int d1, int attraction[]) {
n = n1;
x = start;
d = d1;
for (int i = 0; i < n; i ++) val[i] = attraction[i];
if (!d) return 0;
if (d == 1) return val[start];
return solve();
}
Compilation message (stderr)
holiday.cpp: In function 'long long int solve()':
holiday.cpp:11:6: warning: variable 'left' set but not used [-Wunused-but-set-variable]
int left = 0;
^~~~
# | 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... |