제출 #70747

#제출 시각아이디문제언어결과실행 시간메모리
70747mr_banana팀들 (IOI15_teams)C++17
0 / 100
4043 ms56368 KiB
#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); }*/ int a1[MN],b1[MN]; void init(int N, int a[], int b[]) { n=N; for(int i=0;i<n;i++){ a1[i]=a[i]; b1[i]=b[i]; //add(a[i],b[i]); } //build(); } int num[MN]; int meg[MN]; int can(int m, int k[]) { sort(k,k+m); int p1=-1; int sum=0; 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]; sum+=meg[p1]; if(sum>n){ return 0; } } p1++; int cur=0; for(int i=0;i<p1;i++){ int cnt1=0; for(int j=0;j<n;j++){ if(i && a1[j]<=meg[i-1] && b1[j]>=meg[i]){ cnt1++; } } cur=min(cur,cnt1); for(int j=0;j<n;j++){ if((a1[j]<=meg[i] && b1[j]>=meg[i]) && (i==0 || a1[j]>meg[i-1])){ cur++; } } cur-=num[i]; if(cur<0){ return 0; } } return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...