제출 #361975

#제출 시각아이디문제언어결과실행 시간메모리
361975beksultan04휴가 (IOI14_holiday)C++14
0 / 100
75 ms6380 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-1,d); set <pii> s,u; for (i=0;i<m+1;++i) s.insert({attraction[i],i}); int c = d-m; while (c-- && !s.empty()){ auto tmp = s.end(); tmp--; u.insert(*tmp); ans += tmp->fr; s.erase(tmp); } mx = max(ans,mx); for (i=m;i>=0;--i){ if (u.find({attraction[i],i}) != u.end()){ ans -= attraction[i]; u.erase({attraction[i],i}); if (!s.empty()){ auto tmp = s.end(); tmp--; ans += tmp->fr; u.insert(*tmp); s.erase(tmp); } } else s.erase({attraction[i],i}); if (!s.empty()){ auto tmp = s.end(); tmp--; ans += tmp->fr; s.erase(tmp); } } 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...