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;
const int MN=5e5+100;
vector<int> seg[4*MN];
int n;
/*void add(int p,int x,int v=1,int s=0,int e=n){
if(e-s<2){
seg[v].push_back(x);
return;
}
int mid=(s+e)/2;
if(p<mid){
add(p,x,2*v,s,mid);
}
else{
add(p,x,2*v+1,mid,e);
}
}
void build(int v=1,int s=0,int e=n){
if(e-s<2){
sort(seg[v].begin(),seg[v].end());
return;
}
int mid=(s+e)/2;
build(2*v,s,mid);
build(2*v+1,mid,e);
merge(seg[2*v].begin(),seg[2*v].end(),seg[2*v+1].begin(),seg[2*v+1].end(),seg[v].begin());
}
int query(int l,int r,int x,int v=1,int s=0,int e=n){
if(l<=s && e<=r){
return upper_bound(seg[v].begin(),seg[v].end(),x)-seg[v].begin();
}
if(l>=e || s>=r){
return 0;
}
int mid=(s+e)/2;
return query(l,r,x,2*v,s,mid)+query(l,r,x,2*v+1,mid,e);
}
int query2(int l,int r,int x,int y){
return query(l,r,y)-query(l,r,x);
}*/
pair<int,int> p[MN];
void init(int N, int a[], int b[]) {
n=N;
for(int i=0;i<n;i++){
p[i]={b[i],a[i]};
//add(a[i],b[i]);
}
sort(p,p+n);
//build();
}
bool mark[MN];
int num[MN];
int meg[MN];
int can(int m, int k[]) {
sort(k,k+m);
memset(mark,0,sizeof mark);
int p1=-1;
for(int i=0;i<m;i++){
if(i==0 || k[i]!=k[i-1]){
p1++;
num[p1]=0;
meg[p1]=k[i];
}
num[p1]+=meg[p1];
}
p1++;
long long mx=0;
for(int i=0;i<p1;i++){
for(int j=0;j<n;j++){
if(num[i] && !mark[j] && p[j].second<=meg[i] && p[j].first>=meg[i]){
mark[j]=1;
num[i]--;
}
}
if(num[i]){
return 0;
}
}
return 1;
}
Compilation message (stderr)
teams.cpp: In function 'int can(int, int*)':
teams.cpp:69:15: warning: unused variable 'mx' [-Wunused-variable]
long long mx=0;
^~
# | 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... |