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;
#define ll long long
#define fs first
#define sc second
#define N 500010
#define pb push_back
#define ii pair<int,int>
int n,cnt[N],l[N],r[N];
multiset<int>s;
vector<int>lis[N];
void init(int sl,int a[],int b[])
{
n=sl;
for(int i=1;i<=n;i++)
{
l[i]=a[i-1];
r[i]=b[i-1];
}
for(int i=1;i<=n;i++)
{
lis[l[i]].pb(r[i]);
}
}
ll can(int m,int sz[])
{
memset(cnt,0,sizeof(cnt));
for(int i=0;i<m;i++)
cnt[sz[i]]++;
s.clear();
for(int i=1;i<=n;i++)
{
for(auto u:lis[i])
s.insert(u);
while(!s.empty()&&*s.begin()<i)
s.erase(s.begin());
if(1ll*cnt[i]*i>s.size())
return 0;
for(ll j=1ll*cnt[i]*i;j>=1;j--)
s.erase(s.begin());
}
return 1;
}
#ifdef SKY
int main()
{
freopen("A.inp","r",stdin);
freopen("A.out","w",stdout);
// ios::sync_with_stdio(0);
// cin.tie(NULL);
// cout.tie(NULL);
int n;
cin>>n;
int a[n],b[n];
for(int i=0;i<n;i++)
cin>>a[i]>>b[i];
init(n,a,b);
int q;
cin>>q;
while(q--)
{
int m;
cin>>m;
int k[m];
for(int j=0;j<m;j++)
cin>>k[j];
cout<<can(m,k)<<endl;
}
return 0;
}
#endif // SKY
Compilation message (stderr)
teams.cpp: In function 'long long int can(int, int*)':
teams.cpp:42:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::multiset<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
42 | if(1ll*cnt[i]*i>s.size())
| ~~~~~~~~~~~~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |