# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1043042 | ALeonidou | Holiday (IOI14_holiday) | C++17 | 10 ms | 3792 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 ll long long
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define sz(x) (ll)x.size()
typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <ii> vii;
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl;
void printVct(vi &v){
for (ll i =0; i<sz(v); i++){
cout<<v[i]<<" ";
}
cout<<endl;
}
vi val;
ll n;
long long int findMaxAttraction(int N, int start, int D, int attraction[]) {
ll s = start;
n = N;
ll d = D;
for (ll i= 0; i<n; i++){
val.pb(attraction[i]);
}
if (d == 0) return 0;
//subtask 2:
priority_queue <ll, vi, greater<ll> > pq;
ll ans = val[0];
pq.push(val[0]);
ll cur = val[0];
for (ll i=1; i<min(n, d-1); i++){
ll e = d - i;
cur += val[i];
pq.push(val[i]);
while (e < sz(pq)){
cur -= pq.top();
pq.pop();
}
ans = max(ans, cur);
}
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... |