Submission #361944

#TimeUsernameProblemLanguageResultExecution timeMemory
361944beksultan04Holiday (IOI14_holiday)C++14
0 / 100
74 ms13152 KiB
#include"holiday.h" #ifndef EVAL #include "grader.cpp" #endif #include <bits/stdc++.h> using namespace std; #define lol long long #define pii pair<int,int> #define pll pair<lol,lol> #define OK puts("OK"); #define NO puts("NO"); #define YES puts("YES"); #define fr first #define sc second #define ret return #define scanl(a) scanf("%lld",&a); #define scanll(a,b) scanf("%lld %lld",&a, &b); #define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c); #define scan1(a) scanf("%d",&a); #define scan2(a,b) scanf("%d %d",&a, &b); #define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c); #define all(s) s.begin(),s.end() #define allr(s) s.rbegin(),s.rend() #define pb push_back #define sz(v) (int)v.size() #define endi puts(""); #define eps 1e-12 int N,strt,q[200001]; lol int findMaxAttraction(int n, int start, int d, int attraction[]){ lol ans=0,mx=0,i; vector <pii> v; int m = min(n,d); for (i=0;i<m;++i){ v.pb({attraction[i],i}); } sort(allr(v)); set <pii> s,u; int c = d-m+1; for (i=0;i<c;++i){ u.insert(v[i]); ans += v[i].fr; } for (i=c;i<m;++i){ s.insert(v[i]); } mx = max(mx,ans); for (i=m;i>=0;--i){ if (u.find({attraction[i],i}) != u.end()){ u.erase({attraction[i],i}); ans -= attraction[i]; if (!s.empty()){ auto tmp = s.end(); tmp--; u.insert(*tmp); ans += tmp->fr; s.erase(tmp); if (!s.empty()){ auto tmp = s.end(); tmp--; u.insert(*tmp); ans += tmp->fr; s.erase(tmp); } } } else { s.erase({attraction[i],i}); } mx = max(mx,ans); } ret mx; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...