제출 #994034

#제출 시각아이디문제언어결과실행 시간메모리
994034firewater팀들 (IOI15_teams)C++14
0 / 100
382 ms524288 KiB
#include "teams.h"
#include<bits/stdc++.h>
#define ll long long
#define N 500500
#define M 1010
#define fs first
#define sn second
using namespace std;
int n,B,x,y,now,w,sum,v[M],c[M],h[N][700],g[M][M],f[M][M];
vector<pair<int,int> >d[700];
void init(int NN, int AA[], int BB[]) {
	n=NN;
	B=800;
	for(int i=1;i<=n;++i){
		tie(x,y)=tie(AA[i-1],BB[i-1]);
		h[y][x/B]++;
		d[x/B].push_back({x,y});
	}
	for(int i=0;i<=n/B;++i)
		sort(d[i].begin(),d[i].end(),[](pair<int,int>a,pair<int,int>b){return (a.sn>b.sn);});
	for(int i=n-1;i>0;--i)
		for(int j=0;j<=n/B;++j)
			h[i][j]+=h[i+1][j];
	return;
}

int can(int MM, int K[]) {
	sum=0;
	w=0;
	sort(K,K+MM);
	for(int i=0;i<MM;++i){
		sum+=K[i];
		if(sum>n)return 0;
		if(!w||v[w]!=K[i])v[++w]=K[i],c[w]=K[i];
		else c[w]+=K[i];
	}
	for(int i=0;i<=w+1;++i)
		for(int j=0;j<=w+1;++j)
			g[i][j]=0;
	for(int i=1;i<=w;++i){
		now=v[i]/B;
		x=0;
		for(int j=w;j>=i;--j){
			g[i][j]+=h[v[j]][now-1];
			while(x<d[now].size()&&d[now][x].sn>=v[j]){
				if(d[now][x].fs<=v[i])g[i][j]++;
				x++;
			}
		}
	}
	for(int i=1;i<=w;++i)
		for(int j=i;j<=w;++j)
			f[i][j]=g[i][j]-g[i-1][j]-g[i][j+1]+g[i-1][j+1];
	for(int i=1;i<=w;++i){
		for(int j=i;j<=w;++j){
			x=min(c[i],f[i][j]);
			f[i][j]-=x;
			c[i]-=x;
		}
		if(c[i])return 0;
		for(int j=i+1;j<+w;++j)
			f[i+1][j]+=f[i][j];
	}
	return 1;
}

컴파일 시 표준 에러 (stderr) 메시지

teams.cpp: In function 'int can(int, int*)':
teams.cpp:45:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |    while(x<d[now].size()&&d[now][x].sn>=v[j]){
      |          ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...