제출 #754178

#제출 시각아이디문제언어결과실행 시간메모리
754178nicksms마상시합 토너먼트 (IOI12_tournament)C++17
100 / 100
183 ms6912 KiB
#include <bits/extc++.h> using namespace std; int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) { struct p {int x,y;}; __gnu_cxx::rope<p> g; vector<int> ans(N+1),cl(N),cr(N); int cnt = 0; for (int i = 0; i < N-1; i++) if (K[i] > R) { cl[i+1]++; cr[i]++; cnt++; } partial_sum(cl.begin(),cl.end(),cl.begin()); partial_sum(cr.rbegin(),cr.rend(),cr.rbegin()); for (int i = 0; i < N; i++) g.push_back({i,i}); for (int i = 0; i < C; i++) { int l=g[S[i]].x,r=g[E[i]].y; g.erase(S[i],E[i]-S[i]+1); g.insert(S[i],{l,r}); if (cl[l]+cr[r]==cnt) ans[l]++,ans[r+1]--; } partial_sum(ans.begin(),ans.end(),ans.begin()); return max_element(ans.begin(),ans.begin()+N)-ans.begin(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...