제출 #874230

#제출 시각아이디문제언어결과실행 시간메모리
874230Matjaz마상시합 토너먼트 (IOI12_tournament)C++14
49 / 100
1042 ms2136 KiB
#include <vector> #include <algorithm> #include <iostream> using namespace std; // Insight: each S[i] E[i] corresponds to some interval in the original set of positions // The interval only matters if your player is in it - and there is a unique answer as to whether it wins or loses // You can find the best position with a sweep. int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) { int best_position = 0; int best_wins = 0; vector<pair<int,int> > positions(N); vector<pair<int,int> > intervals(C); for (int i=0;i<N;i++) positions[i] = make_pair(i,i); for (int i=0;i<C;i++){ intervals[i] = make_pair(positions[S[i]].first, positions[E[i]].second); positions[S[i]] = intervals[i]; for (int j=E[i]+1;j<N;j++) positions[S[i] + j - E[i]] = positions[j]; } vector<int> s(N+1); s[0] = 0; for (int i=1;i<=N;i++) s[i] = s[i-1] + (K[i-1] > R); for (int p=0;p<N;p++){ int wins = 0; for (int i=0;i<C;i++){ if (intervals[i].first <= p && p <= intervals[i].second){ if (s[intervals[i].second] - s[intervals[i].first] == 0) wins++; } } if (wins > best_wins){ best_wins = wins; best_position = p; } } return best_position; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...