[2008年NOIP普及组] 排座椅
作者:互联网
用桶排排序,用贪心找出最优解
#include<bits/stdc++.h>
using namespace std;
int m,n,k,d,l,a,b,c,e,maxs,bj;
int i,j,ii,mm[33000],ll[23000],ms[33000],ls[33000];
int main(){
cin>>m>>n>>k>>l>>d;
for(j=1;j<=d;j++){
cin>>a>>b>>c>>e;
if(a==c){
if(b>e){
ll[e]++;
}
else{
ll[b]++;
}
}
else{
if(a>c){
mm[c]++;
}
else{
mm[a]++;
}
}
}
for(j=1;j<=k;j++){
maxs=-1;
bj=0;
for(i=1;i<=m;i++){
if(maxs<=mm[i]){
maxs=mm[i];
bj=i;
}
}
mm[bj]=0;
ms[j]=bj;
}
for(j=1;j<=k;j++){
for(i=j+1;i<=k;i++){
if(ms[j]>ms[i]){
int t=ms[j];
ms[j]=ms[i];
ms[i]=t;
}
}
cout<<ms[j]<<" ";
}
cout<<endl;
for(j=1;j<=l;j++){
maxs=-1;
bj=0;
for(i=1;i<=n;i++){
if(maxs<=ll[i]){
maxs=ll[i];
bj=i;
}
}
ll[bj]=0;
ls[j]=bj;
}
for(j=1;j<=l;j++){
for(i=j+1;i<=l;i++){
if(ls[j]>ls[i]){
int t=ls[j];
ls[j]=ls[i];
ls[i]=t;
}
}
cout<<ls[j]<<" ";
}
}
标签:NOIP,int,maxs,ll,bj,座椅,ls,ms,2008 来源: https://www.cnblogs.com/wangjunlong9948/p/16581969.html