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模拟)的更多相关文章

  1. CodeForces 730A Toda 2 (模拟)

    题意:给定一个序列,现在你每次至多给5个人的权值减小1,最少2个人,最小是0,使得剩下的所有权值都相等且尽量大. 析:用multiset来模拟,每次取权值最大的三个或者两个,直到最后相等.我开始没有这 ...

  2. CodeForces.158A Next Round (水模拟)

    CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...

  3. CodeForces - 730A 贪心+模拟

    贪心策略: 1.只有一个最大值,选着第二大的一起参加比赛减分. 2.有奇数个最大值,选择三个进行比赛. 3.偶数个最大值,选择两个进行比赛. 为什么不把最大值全部选择? 因为最多只能选五个,有可能选择 ...

  4. Codeforces 747C:Servers(模拟)

    http://codeforces.com/problemset/problem/747/C 题意:有n台机器,q个操作.每次操作从ti时间开始,需要ki台机器,花费di的时间.每次选择机器从小到大开 ...

  5. Codeforces 740A. Alyona and copybooks 模拟

    A. Alyona and copybooks time limit per test: 1 second memory limit per test: 256 megabytes input: st ...

  6. 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 ...

  7. CodeForces 670 A. Holidays(模拟)

    Description On the planet Mars a year lasts exactly n days (there are no leap years on Mars). But Ma ...

  8. Codeforces 280D k-Maximum Subsequence Sum [模拟费用流,线段树]

    洛谷 Codeforces bzoj1,bzoj2 这可真是一道n倍经验题呢-- 思路 我首先想到了DP,然后矩阵,然后线段树,然后T飞-- 搜了题解之后发现是模拟费用流. 直接维护选k个子段时的最优 ...

  9. 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 ...

随机推荐

  1. 漫谈 JVM —— 内存

    JVM 是什么呢?说的直白点就是 Java 代码运行的地方,全称 Java Virtural Machine,Java 虚拟机.有的人就会奇怪了,为什么 Java 程序员需要了解这个东西?毕竟大多数情 ...

  2. sql学习目录

    sql like N'%...%' 在C#里的写法 sql 循环 随机数创建数据 使用StringBuilder与SqlParameter 跨库查询数据 sql 多列求和 sql SCOPE_IDEN ...

  3. linux 用蓝牙和手机通信

    加载模块: # modprobe hci_usb    # modprobe rfcomm    # hciconfig hci0 up # hciconfig hci0 up 查看状况: # hci ...

  4. 使用IntelliJ IDEA开发SpringMVC网站(五)博客文章管理

    原文:使用IntelliJ IDEA开发SpringMVC网站(五)博客文章管理 摘要 通过对博客文章的管理,实现外键操作. 目录[-] 八.博客文章管理 1.查看文章 2.添加博客        3 ...

  5. enum 枚举一般用法 dotnet

    public enum Demo { [Description("Moning描述")] Moning = , [Description("Afternoon描述&quo ...

  6. redis的简介和使用

    简介 redis(Remote Dictionary Server)是一种Nosql技术,它是一个开源的高级kv存储和数据结构存储系统,它经常被拿来和Memcached相比较,但是Memcached不 ...

  7. HTTP通信过程原理

    HTTP协议 通信过程介绍 HTTP协议介绍 Http(Hypertext Transfer Protocol)超文本传输协议. Http是应用层协议,当你上网浏览网页的时候,浏览器和服务器之间就会通 ...

  8. wchar_t string on Linux, OS X and Windows

    Making wchar_t work on Linux, OS X and Windows for CMarkup release 10.1 I learned a couple of humble ...

  9. Delphi 7下IGDIPlus库的使用

    IGDI+是一个免费开源封装微软GDI+功能的Delphi库,该库使得可以用Delphi语言代码快速简短的实现复杂GDI+应用程序.官方网站:http://www.mitov.com/html/igd ...

  10. DLL里面socket(Delphi的代码)

    http://hi.baidu.com/game_base/item/f617e4136414148889a956ed   本文简单介绍了当前Windows支持的各种Socket I/O模型,如果你发 ...