# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
992558 | Khanhcsp2 | Holiday (IOI14_holiday) | C++14 | 0 ms | 0 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>
#define el '\n'
#define fi first
#define sc second
#define int ll
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
const int mod=1e9+7;
const int N=1e5+11;
priority_queue<ll, vector<ll>, greater<ll>> q;
ll a[N], n, b[N], s, d;
ll findMaxAttraction(ll n, ll start, ll d, ll attraction[])
{
for(ll i=0;i<n;i++) a[i+1]=attraction[i];
ll sum=0, ans=a[1];
if(d==0) return 0;
for(ll i=1;i<d;i++) q.push(0);
sum+=a[1];
q.push(a[1]);
for(ll i=2;i<=n;i++)
{
sum+=a[i];
q.push(a[i]);
sum-=q.top();
q.pop();
sum-=q.top();
q.pop();
ans=max(ans, sum);
if(q.empty()) break;
}
return ans;
}
//void sol()
//{
// cin >> n >> s >> d;
// for(ll i=0;i<n;i++) cin >> b[i];
// cout << findMaxAttraction(n, s, d, b);
//}
//signed main()
//{
//// freopen("divisor.INP", "r", stdin);
//// freopen("divisor.OUT", "w", stdout);
// ios_base::sync_with_stdio(0);
// cin.tie(0);
// ll t=1;
// //cin >> t;
// while(t--)
// {
// sol();
// }
//}