博客
关于我
agc018B Sports Festival
阅读量:300 次
发布时间:2019-03-01

本文共 1063 字,大约阅读时间需要 3 分钟。

题目链接

题意简述

n n n个人 m m m种运动,每个人给出了喜好每种运动的顺序,越靠前表示越喜欢。现在你需要选取一些运动,每个人会选取这些运动里他最喜欢的那个参加,求参加运动人数最多的运动的参加人数最少是多少。

题解

如果一个运动被 k k k个人选取了,那么删掉其他的运动,这个运动参加的人数不会变少。那么每次删掉参加人数最多的那些运动,取每次删的那种运动人数最小值即可。

代码

#include 
#include
int read(){ int x=0,f=1; char ch=getchar(); while((ch<'0')||(ch>'9')) { if(ch=='-') { f=-f; } ch=getchar(); } while((ch>='0')&&(ch<='9')) { x=x*10+ch-'0'; ch=getchar(); } return x*f;}const int maxn=300;const int inf=0x3f3f3f3f;int n,m,a[maxn+4][maxn+4],in[maxn+4],mx[maxn+4],ans;int main(){ n=read(); m=read(); for(int i=1; i<=n; ++i) { for(int j=1; j<=m; ++j) { a[i][j]=read(); } } ans=n; int cnt=0; while(cnt
now)) { now=mx[j]; } } ans=std::min(ans,now); for(int j=1; j<=m; ++j) { if((!in[j])&&(mx[j]==now)) { in[j]=1; ++cnt; } } } printf("%d\n",ans); return 0;}

转载地址:http://ccwo.baihongyu.com/

你可能感兴趣的文章
NodeJs入门知识
查看>>
nodejs包管理工具对比:npm、Yarn、cnpm、npx
查看>>
NodeJs单元测试之 API性能测试
查看>>
nodejs图片转换字节保存
查看>>
nodejs在Liunx上的部署生产方式-PM2
查看>>
nodejs基于art-template模板引擎生成
查看>>
nodejs字符与字节之间的转换
查看>>
NodeJs学习笔记001--npm换源
查看>>
NodeJs学习笔记002--npm常用命令详解
查看>>
nodejs学习笔记一——nodejs安装
查看>>
vue3+Element-plus icon图标无法显示的问题(已解决)
查看>>
NodeJS实现跨域的方法( 4种 )
查看>>
nodejs封装http请求
查看>>
nodejs常用组件
查看>>
nodejs开发公众号报错 40164,白名单配置找不到,竟然是这个原因
查看>>
Nodejs异步回调的处理方法总结
查看>>
NodeJS报错 Fatal error: ENOSPC: System limit for number of file watchers reached, watch ‘...path...‘
查看>>
nodejs支持ssi实现include shtml页面
查看>>
Nodejs教程09:实现一个带接口请求的简单服务器
查看>>
nodejs服务端实现post请求
查看>>