Codeforces 730A:Toda 2(multiset模拟)
http://codeforces.com/problemset/problem/730/A
题意:有n个人打天梯,想让这n个人的分数相同,每场比赛必须有2-5个人参赛,参赛的人会降低一分,问一个合理方案让所有人的分数相同。
思路:不限制比赛场数,那么只用考虑2-3个人参赛的情况(因为4和5可以由2和3组成)。但是这个时候就不知道什么时候用3什么时候用2了。。
看别人代码。只有最大的三个数是一样的时候才用3,其他时候都用2。
然后很暴力地用multiset来模拟比赛。
#include <bits/stdc++.h>
using namespace std;
#define N 105
struct node {
int r, id;
friend bool operator < (const node &a, const node &b) { return a.r > b.r; }
};
multiset<node> s;
vector<string> res; int main() {
int n, r;
scanf("%d", &n);
for(int i = ; i <= n; i++)
scanf("%d", &r), s.insert((node) {r, i});
while(s.begin()->r != s.rbegin()->r) {
vector<node> tmp; string ans;
for(int i = ; i < n; i++) ans += '';
int cnt = ;
if(s.count(*s.begin()) == ) cnt = ;
for(int i = ; i < cnt; i++) {
node now = *s.begin(); s.erase(s.begin());
ans[now.id-] = '';
if(now.r > ) now.r--;
tmp.push_back(now);
}
for(int i = ; i < cnt; i++) s.insert(tmp[i]);
res.push_back(ans);
}
printf("%d\n%d\n", s.begin()->r, res.size());
for(int i = ; i < res.size(); i++) cout << res[i] << endl;
return ;
}
Codeforces 730A:Toda 2(multiset模拟)的更多相关文章
- CodeForces 730A Toda 2 (模拟)
题意:给定一个序列,现在你每次至多给5个人的权值减小1,最少2个人,最小是0,使得剩下的所有权值都相等且尽量大. 析:用multiset来模拟,每次取权值最大的三个或者两个,直到最后相等.我开始没有这 ...
- CodeForces.158A Next Round (水模拟)
CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...
- CodeForces - 730A 贪心+模拟
贪心策略: 1.只有一个最大值,选着第二大的一起参加比赛减分. 2.有奇数个最大值,选择三个进行比赛. 3.偶数个最大值,选择两个进行比赛. 为什么不把最大值全部选择? 因为最多只能选五个,有可能选择 ...
- Codeforces 747C:Servers(模拟)
http://codeforces.com/problemset/problem/747/C 题意:有n台机器,q个操作.每次操作从ti时间开始,需要ki台机器,花费di的时间.每次选择机器从小到大开 ...
- Codeforces 740A. Alyona and copybooks 模拟
A. Alyona and copybooks time limit per test: 1 second memory limit per test: 256 megabytes input: st ...
- Codeforces 716A Crazy Computer 【模拟】 (Codeforces Round #372 (Div. 2))
A. Crazy Computer time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- CodeForces 670 A. Holidays(模拟)
Description On the planet Mars a year lasts exactly n days (there are no leap years on Mars). But Ma ...
- Codeforces 280D k-Maximum Subsequence Sum [模拟费用流,线段树]
洛谷 Codeforces bzoj1,bzoj2 这可真是一道n倍经验题呢-- 思路 我首先想到了DP,然后矩阵,然后线段树,然后T飞-- 搜了题解之后发现是模拟费用流. 直接维护选k个子段时的最优 ...
- Codeforces 1090B - LaTeX Expert - [字符串模拟][2018-2019 Russia Open High School Programming Contest Problem B]
题目链接:https://codeforces.com/contest/1090/problem/B Examplesstandard input The most famous characters ...
随机推荐
- 读取spring工程中resource的文件
Resource resource = new ClassPathResource("data.json"); // 读文件到字符串 String fileContent = Fi ...
- Unpaired/Partially/Unsupervised Image Captioning
这篇涉及到以下三篇论文: Unpaired Image Captioning by Language Pivoting (ECCV 2018) Show, Tell and Discriminate: ...
- 微信小程序把玩(四十一)canvas API
原文:微信小程序把玩(四十一)canvas API 绘图是每个移动应用必备的技术,基本上和Android,IOS,等移动开发都是相同的,创建个上下文,给你个画布再上画,官网给的小例子都比较全了自己去看 ...
- missing equal sign
"UPDATE TB_BOOKINGSET REC_LOC_CODE = ?,CUSTOMER_ADDR?WHERE BOOKING_NO=? AND TRANSPORT_MODE=? &q ...
- UWP开发-获取设备唯一ID
EasClientDeviceInformation deviceInfo = new EasClientDeviceInformation(); this.showDeviceInfo.Items. ...
- Android Java调用Qt写的so库
有时候,我们反编译apk得到一个so库,如果直接使用这个so库的话,必须使用原来so库同样的package名字,才能用.这样人家反编译你的apk,就知道你侵犯了人家的版权.为了达到混淆的目的,我们可以 ...
- 配置QtCreator+CDB远程调试环境(用到了符号表) good
相关环境信息:开发机Win7 x64.远程机器WinXP.调试器是CDB.Qt版本5.2.1 一.部署远程机器环境 我这里用的是虚拟机(Windows XP),根据你要调试的程序选择安装不同架构的Wi ...
- Hadoop 3、Hadoop 分布式存储系统 HDFS(好多彩色图)
HDFS是Hadoop Distribute File System 的简称,也就是Hadoop的一个分布式文件系统. 一.HDFS的优缺点 1.HDFS优点: a.高容错性 .数据保存多个副本 .数 ...
- ZooKeeper+Dubbo+SpringBoot 微服务Demo搭建
1. 首先创建springBoot项目,springBoot是一堆组件的集合,在pom文件中对需要的组件进行配置.生成如下目录结构 创建test项目,同步在test创建dubbo-api,dubbo- ...
- android 写文件到sd卡问题小记
android 写文件到sd卡问题小记 事情是这样子的.... 这天我开始编写项目调试工具,高大上不?-----其实就是记录实时网络请求和崩溃日志相关等的小工具(此处一个会心的微笑). 然后我是这样写 ...