Submission #837250

#TimeUsernameProblemLanguageResultExecution timeMemory
837250mindiyakTeams (IOI15_teams)C++14
0 / 100
4067 ms16256 KiB
#include "teams.h" #include <vector> #include <queue> #include <algorithm> using namespace std; int n; vector<pair<int,int>> arr; void init(int N, int A[], int B[]) { n=N; for(int i=0;i<n;i++)arr.push_back({A[i],B[i]}); sort(arr.begin(),arr.end()); } int can(int M, int K[]) { int sum = 0; vector<int>q; for(int i=0;i<M;i++)sum += K[i]; for(int i=0;i<M;i++)q.push_back(K[i]); if(sum > n)return 0; int skip = n-sum; int pos = 0; int minT = n; int cur = 0; int cnt = 0; sort(q.begin(),q.end()); while(true){ if(arr[pos].second < q[cnt] or arr[pos].first > q[cnt]){ if(skip>0)skip--; else{return 0;} }else{ minT = min(minT,arr[pos].second); cur++; if(q[cnt] == cur){ cnt++; cur = 0; minT=n; } if(cnt == M)return 1; } pos ++; if(pos == n)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...