Submission #782838

#TimeUsernameProblemLanguageResultExecution timeMemory
782838Sohsoh84Teams (IOI15_teams)C++17
34 / 100
4066 ms43368 KiB
#include "teams.h" #include <bits/stdc++.h> using namespace std; #define debug(x) cerr << #x << ": " << x << endl; const int MAXN = 1e6 + 10; int n, F[MAXN]; vector<int> L[MAXN]; void init(int N, int A[], int B[]) { n = N; for (int i = 0; i < n; i++) L[A[i]].push_back(B[i]); } int can(int M, int K[]) { for (int i = 0; i < MAXN; i++) F[i] = 0; int m = M, s = 0; for (int i = 0; i < m; i++) { F[K[i]]++; s += K[i]; if (s > n) return 0; } priority_queue<int, vector<int>, greater<int>> pq; for (int l = 0; l <= n; l++) { while (!pq.empty() && pq.top() < l) pq.pop(); for (int r : L[l]) { pq.push(r); } while (F[l]--) { int x = l; while (x--) { if (pq.empty()) return 0; pq.pop(); } } } 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...