제출 #528335

#제출 시각아이디문제언어결과실행 시간메모리
528335Cyanmond팀들 (IOI15_teams)C++17
34 / 100
4073 ms32700 KiB
// clang-format off #include <bits/stdc++.h> int N; std::vector<int> A, B; void init(int n, int a[], int b[]) { N = n; A.resize(N); B.resize(N); for (int i = 0; i < N; ++i) { A[i] = a[i]; B[i] = b[i]; } } int internal_can(const int M, std::vector<int> K) { int sum = 0; // overflow for (int i = 0; i < M; ++i) { sum += K[i]; if (sum > N) return 0; } std::sort(K.begin(), K.end()); std::vector<std::vector<int>> event_a(N + 1); for (int i = 0; i < N; ++i) event_a[A[i]].push_back(B[i] + 1); std::vector<int> event_q(N + 1); for (int i = 0; i < M; ++i) ++event_q[K[i]]; std::priority_queue<int, std::vector<int>, std::greater<int>> pq; for (int i = 1; i <= N; ++i) { for (const int r : event_a[i]) pq.push(r); while (event_q[i]--) { int c = i; while (c--) { while ((not pq.empty()) and pq.top() <= i) pq.pop(); if (pq.empty()) return 0; pq.pop(); } } } return 1; } int can(int M, int K[]) { std::vector<int> k(M); for (int i = 0; i < M; ++i) k[i] = K[i]; return internal_can(M, k); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...