Submission #885655

#TimeUsernameProblemLanguageResultExecution timeMemory
885655nguyentunglamTeams (IOI15_teams)C++17
0 / 100
4049 ms10064 KiB
#include<bits/stdc++.h> #define fi first #define se second #define endl "\n" #define ii pair<int, int> #define all(v) v.begin(), v.end() using namespace std; const int N = 1e5 + 10; pair<int, int> a[N]; int n; void init(int _n, int A[], int B[]) { n = _n; for(int i = 1; i <= n; i++) { a[i] = make_pair(A[i - 1], B[i - 1]); } sort(a + 1, a + n + 1); } int can (int m, int k[]) { sort(k + 1, k + m + 1); priority_queue<int, vector<int>, greater<int> > q; for(int i = 0, j = 1; i < m; i++) { int x = k[i]; while (j <= n && a[j].first <= x) { q.push(a[j].second); j++; } int cnt = x; while (!q.empty() && cnt > 0) { int y = q.top(); q.pop(); if (y >= x) cnt--; } if (cnt) return 0; } return 1; } #ifdef ngu int32_t main() { freopen ("task.inp", "r", stdin); freopen ("task.out", "w", stdout); int n; cin >> n; int *A = (int *)malloc(sizeof(int) * (unsigned int)N); int *B = (int *)malloc(sizeof(int) * (unsigned int)N); for(int i = 0; i < n; i++) cin >> A[i] >> B[i]; init(n, A, B); int q; cin >> q; while (q--) { int m; cin >> m; int *k = (int *)malloc(sizeof(int) * (unsigned int)m); for(int i = 0; i < m; i++) cin >> k[i]; cout << can(m, k) << endl; } } #endif // ngu
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...