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<bits/stdc++.h>
using namespace std;
int a[100001];
int b[100001];
vector<int>use[100001];
int vis[100001];
bool cmp(int i,int j){
return b[i]<b[j];
}
int n;
void init(int N,int A[],int B[]){
n=N;
for (int i=1;i<=n;i++){
a[i]=A[i-1];
b[i]=B[i-1];
}
for (int i=1;i<=n;i++){
for (int j=1;j<=n;j++){
if (a[j]<=i&&b[j]>=i){
use[i].push_back(j);
}
}
sort(use[i].begin(),use[i].end(),cmp);
}
}
int can(int M,int K[]){
for (int i=1;i<=n;i++)vis[i]=0;
sort(K,K+M);
for (int i=0;i<M;i++){
int cnt=0;
for (auto v:use[K[i]]){
if (cnt==K[i])break;
if (vis[v])continue;
vis[v]=1;
cnt++;
}
if (cnt<K[i])return 0;
}
return 1;
}
/*int K[100001];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
srand(time(NULL));
//freopen("test.INP","r",stdin);
//freopen(".OUT","w",stdout);
//init(4,{1,2,2,2},{2,3,3,4});
cin>>n;
for (int i=1;i<=n;i++)cin>>a[i]>>b[i];
for (int i=1;i<=n;i++){
for (int j=1;j<=n;j++){
if (a[j]<=i&&b[j]>=i){
use[i].push_back(j);
}
}
sort(use[i].begin(),use[i].end(),cmp);
}
int q;
cin>>q;
for (int test=1;test<=q;test++){
int M;
cin>>M;
for (int i=0;i<M;i++)cin>>K[i];
for (int i=1;i<=n;i++)vis[i]=0;
sort(K,K+M);
int ans=1;
for (int i=0;i<M;i++){
int cnt=0;
for (auto v:use[K[i]]){
if (cnt==K[i])break;
if (vis[v]==1)continue;
vis[v]=1;
cnt++;
}
if (cnt<K[i])ans=0;
}
cout<<ans<<'\n';
}
4
2 4
1 2
2 3
2 3
2
2 1 3
2 1 1
}*/
# | 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... |