# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
132318 | reda | 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>
using namespace std ;
# include "teams.h"
vector<pair<int,int>> v;
void init( int n , int a[] , int b[])
{
for(int i= 0; i < n ; i ++)
{
v.push_back(make_pair(a[i],b[i]));
}
sort(v.begin(),v.end());
}
bool can(int M, int K[])
{
set < pair <int, int> > s;
int p = 0;
sort(K, K + M);
for(int i = 0; i < M; i ++)
{
int flag = K[i];
while(p < v.size() && flag > 0)
{
s.insert({v[p].second, p});
p++;
while( flag> 0 && !s.empty())
{
pair <int, int> it = *s.begin();
if(it.first <= K[i] && K[i] <= v[it.second].first)
{
s.erase(s.begin());
flag--;
}
else if(v[it.second].first < K[i])s.erase(s.begin());
else break;
}
}
if(flag > 0) return false;
}
return true;
}