# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
398067 | MeGustaElArroz23 | Teams (IOI15_teams) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "teams.h"
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
//init(N, A, B) — The grader will call this function first and exactly once.
//can(M, K) — After calling init once, the grader will call this function times in a row, once for each day.
vii v;
ll n;
void init(ll x, ll a[], ll b[]){
n=x;
v=vii(n);
for (ll i=0;i<n;i++){
v[i]=pii{a[i],b[i]};
}
sort(v.begin(),v.end());
}
ll can(ll m, ll k[]){
vi q(m);
for (ll i=0;i<m;i++) q[i]=k[i];
sort(q.begin(),q.end());
priority_queue<ll> cola;
ll i=0;
for (ll j=0;j<m;j++){
ll s=q[j];
while (i<n and v[i].first<=s){
cola.push(-v[i].second);
i++;
}
while (cola.size()>0 and -cola.top()<s) cola.pop();
if (cola.size()>=s){
for (ll h=0;h<s;h++) cola.pop();
}
else return 0;
}
return 1;
}