Submission #936818

#TimeUsernameProblemLanguageResultExecution timeMemory
936818PagodePaivaTeams (IOI15_teams)C++17
0 / 100
37 ms16580 KiB
#include "teams.h" #include<bits/stdc++.h> using namespace std; int n; vector <pair <int, int>> v; void init(int N, int A[], int B[]) { n = N; for(int i = 0;i < n;i++){ v.push_back({A[i], B[i]}); } return; } int can(int M, int K[]) { vector <int> k; int m = M; for(int i = 0;i < m;i++){ k.push_back(K[i]); } sort(k.begin(), k.end()); vector <pair <int, int>> conc; for(int i = 0;i < n;i++){ if(v[i].second < k[0] or v[i].first > k[m-1]) continue; int l = 0, r = m-1; while(r-l > 1){ int mid = (l+r)/2; if(k[mid] > v[i].second){ r = mid-1; } else l = mid; } if(k[r] <= v[i].second) l = r; else r = l; int a = l; l = 0; r = m-1; while(r - l > 1){ int mid = (l+r)/2; if(k[mid] < v[i].first){ l = mid+1; } else r = mid; } if(v[i].first <= k[l]) r = l; else l = r; int b = l; conc.push_back({k[a], k[b]}); // cout << a << ' ' << b << endl; } sort(conc.begin(), conc.end()); int l = n-1; reverse(k.begin(), k.end()); for(auto x : k){ int cnt = x; while(cnt > 0){ if(l < 0) return 0; // cout << v[l].first << ' ' << v[l].second << ' ' << x << endl; if(conc[l].first <= x and x <= conc[l].second){ cnt--; } l--; } } 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...