Submission #1043042

#TimeUsernameProblemLanguageResultExecution timeMemory
1043042ALeonidouHoliday (IOI14_holiday)C++17
23 / 100
10 ms3792 KiB
#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)

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:31:5: warning: unused variable 's' [-Wunused-variable]
   31 |  ll s = start;
      |     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...