Submission #591078

#TimeUsernameProblemLanguageResultExecution timeMemory
591078jakubdTeams (IOI15_teams)C++17
0 / 100
38 ms16232 KiB
#include "teams.h" #include <bits/stdc++.h> using namespace std; vector<int> a, b, p; void init(int N, int A[], int B[]) { a.resize(N); p.resize(N); iota(p.begin(), p.end(), 0); for (int i = 0; i < N; i++) { a[i] = A[i]; b[i] = B[i]; } sort(p.begin(), p.end(), [&](int x, int y) { if (a[x] == a[y]) return b[x] < b[y]; return a[x] < a[y]; }); } int can(int M, int K[]) { sort(K, K + M); int ind = 0, n = (int)a.size(); set<pair<int, int>> st; for (int i = 0; i < M; i++) { while (!st.empty() && st.begin()->first < K[i]) st.erase(st.begin()); while (ind < n && a[p[ind]] <= K[i]) { st.insert({b[p[ind]], ind}); ind++; } if ((int)st.size() < K[i]) { return 0; } for (int it = 0; it < K[i]; it++) { st.erase(st.begin()); } } 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...