Submission #592672

#TimeUsernameProblemLanguageResultExecution timeMemory
592672l_rehoTeams (IOI15_teams)C++14
34 / 100
4042 ms16296 KiB
#include <bits/stdc++.h> using namespace std; vector<pair<int, int>> ranges; int n; bool compare(pair<int, int> p1, pair<int, int> p2){ return (p1.second < p2.second) || ((p1.second == p2.second && p1.first > p2.first)); } void init(int N, int A[], int B[]) { n = N; for(int i = 0; i < N; i++) ranges.push_back({A[i], B[i]}); sort(ranges.begin(), ranges.end(), compare); } int can(int M, int K[]) { vector<bool> assigned(n, false); sort(K, K+M); for(int i = 0; i < M; i++){ // cerco lo studente più a sinsistra in ranges che contiene K int cnt = 0; bool ok = false; // naive O(N) for(int j = 0; j < n; j++){ int start = ranges[j].first; int end = ranges[j].second; if(start <= K[i] && end >= K[i] && !assigned[j]) cnt++, assigned[j] = true; if(cnt == K[i]){ok = true; break;} } // logn O(logN) // dato un indice k, determinare il numero di ranges che contengono K[i] nel prefisso [0,k] (assegnabili) if(!ok) return 0; } 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...