# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
204048 | Segtree | 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"teams.h"
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
vector<P> v;
void init(int N,int A[],int B[]){
rep(i,N)v.push_back(make_pair(A[i],B[i]));
sort(v.begin(),v.end());
}
bool can(int M,int K[]){
sort(K,K+M);
priority_queue<ll,vector<ll>,greater<ll> >pq;
int j=0;
rep(i,M){
for(;j<v.size()&&v[j].first<=K[i];j++){
pq.push(v[j].second);
}
while(!pq.empty()){
if(pq.top()<K[i])pq.pop();
else break;
}
if(pq.size()<K[i])return 0;
rep(k,K[i])pq.pop();
}
return 1;
}
/*
int main(){
int n,a[110],b[110];
cin>>n;
rep(i,n)cin>>a[i]>>b[i];
init(n,a,b);
while(1){
int m,k[110];
cin>>m;
rep(i,m)cin>>k[i];
cout<<(can(m,k)?"YES":"NO")<<endl;
}
}*/