Submission #60741

#TimeUsernameProblemLanguageResultExecution timeMemory
60741istleminTeams (IOI15_teams)C++14
34 / 100
4096 ms56012 KiB
#include "teams.h" #include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i = a; i<int(b);++i) #define all(v) v.begin(),v.end() #define sz(v) v.size() #define trav(a,c) for(auto a: c) typedef long long ll; typedef vector<ll> vi; typedef pair<ll,ll> pii; ll n; vi a; vi b; void init(int N, int A[], int B[]) { n = N; a.resize(n); b.resize(n); rep(i,0,n) { a[i] = A[i]-1; b[i] = B[i]-1; } } int can(int M, int K[]) { vi k; k.assign(n,0); rep(i,0,M) k[K[i]-1] += K[i]; vi add(n+1); vector<vi> ends(n); rep(i,0,n){ ends[a[i]].push_back(b[i]+1); add[a[i]]++; add[b[i]+1]--; } ll sum = 0; multiset<ll> currEnds; rep(i,0,n){ while(currEnds.size()&&*currEnds.begin()==i){ currEnds.erase(currEnds.begin()); } sum+=add[i]; rep(j,0,ends[i].size()) currEnds.insert(ends[i][j]); if(k[i]>sum) { //cout<<0<<endl; return 0; } sum-=k[i]; rep(j,0,k[i]){ add[*currEnds.begin()]++; currEnds.erase(currEnds.begin()); } } //cout<<1<<endl; 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...