# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1072682 | ProtonDecay314 | Holiday (IOI14_holiday) | C++17 | 10 ms | 2836 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;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vpi> vvpi;
typedef vector<vpll> vvpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef short int si;
typedef vector<si> vsi;
typedef vector<vsi> vvsi;
#define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define L(varll, mn, mx) for(ll varll = (mn); varll < (mx); varll++)
#define LR(varll, mx, mn) for(ll varll = (mx); varll > (mn); varll--)
#define LI(vari, mn, mx) for(int vari = (mn); vari < (mx); vari++)
#define LIR(vari, mx, mn) for(int vari = (mx); vari > (mn); vari--)
#define INPV(varvec) for(auto& varveci : (varvec)) cin >> varveci
#define fi first
#define se second
#define pb push_back
#define INF(type) numeric_limits<type>::max()
#define NINF(type) numeric_limits<type>::min()
#define TCASES int t; cin >> t; while(t--)
ll findMaxAttraction(int n, int start, int d, int attraction[]) {
ll cur_sum = 0ll;
ll ans = 0ll;
priority_queue<ll, vector<ll>, greater<ll>> q;
L(i, 0ll, n) {
// Expand the interval
// Compute the new max number to pick
ll count_pick = d - i;
ll curv = attraction[i];
if(count_pick == 0ll) break;
if(q.size() < count_pick) {
q.push(curv);
cur_sum += curv;
} else {
// Remove elements as needed
ll top_elem = q.top();
if(q.size() > count_pick) {
cur_sum -= top_elem;
q.pop();
}
// Replace elements as needed
top_elem = q.top();
if(top_elem < curv) {
cur_sum -= top_elem;
q.pop();
cur_sum += curv;
q.push(curv);
}
}
ans = max(ans, cur_sum);
}
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... |