Submission #726340

#TimeUsernameProblemLanguageResultExecution timeMemory
726340TheSahibTeams (IOI15_teams)C++17
0 / 100
4057 ms33984 KiB
#include "teams.h" #include <bits/stdc++.h> #define ll long long #define pii pair<int, int> using namespace std; int n; vector<pii> 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]}); } } int can(int M, int K[]) { sort(K, K + M); vector<int> events[n + 1]; for (int i = 0; i < n; i++) { events[v[i].first].push_back(0); if(v[i].second + 1 <= n){ events[v[i].second + 1].push_back(1); } } for (int i = 0; i <= n; i++) { sort(events[i].begin(), events[i].end()); } int j = 0; int cnt = 0; int used = 0; for (int x = 0; x <= n && j != M; x++) { for(int e:events[x]){ if(e == 0){ ++cnt; } else{ --cnt; used = max(0, used - 1); } } while(x == K[j]){ if(cnt - used < K[j]){ return false; } used += K[j]; ++j; if(j == M) break; } } return true; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...