제출 #285870

#제출 시각아이디문제언어결과실행 시간메모리
285870DystoriaX팀들 (IOI15_teams)C++14
0 / 100
99 ms23160 KiB
#include "teams.h" #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <bitset> // #include <numeric> using namespace std; int n; int prefix[500010], suffix[500010]; vector<pair<int, int> > pt; void init(int N, int A[], int B[]) { n = N; for(int i = 0; i < n; i++){ prefix[B[i]]++; suffix[A[i]]++; } for(int i = 1; i <= n; i++) prefix[i] += prefix[i - 1]; for(int i = n - 1; i; i--) suffix[i] += suffix[i + 1]; } int can(int M, int K[]) { long long sum = 0; for(int i = 0; i < M; i++) sum += K[i]; if(sum > n) return 0; sort(K, K + M); pt.clear(); int cnt = K[0]; for(int i = 1; i < M; i++){ if(K[i] != K[i - 1]){ pt.emplace_back(K[i - 1], cnt); cnt = K[i]; } else { cnt += K[i]; } } pt.emplace_back(K[M - 1], cnt); int mn = n - prefix[pt[0].first - 1], pref = 0; for(auto &k : pt){ if(pref + k.second + suffix[k.first + 1] > mn) return 0; mn = min(mn, n + pref - prefix[k.first - 1]); pref += k.second; } return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...