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. docker端口映射或启动容器时报错Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen

    现象: [root@localhost ~]# docker run -d -p 9000:80 centos:httpd /bin/sh -c /usr/local/bin/start.shd5b2 ...

  2. QT实现鼠标钩子(使用SetWindowsHookEx安装mouseProc函数)

    HHOOK mouseHook=NULL; LRESULT CALLBACK mouseProc(int nCode,WPARAM wParam,LPARAM lParam ) { if(nCode ...

  3. DataGrid数据绑定

    后台数据绑定 用户场景是生成报表,展示公司各员工每个月的绩效 数据结构 包括报表和单个员工绩效两个实体 public class Report { /// <summary> /// 统计 ...

  4. 利用WIX制作安装包(2)

    原文 利用WIX制作安装包(2) 这一篇文章将为大家介绍如何使用WIX自定义UI.上一篇文章我们讲过WIX为我们提供了五种安装界面.每种安装界面都是由不同的Dialog组成.在这里我们挑选一种比较常用 ...

  5. Image Paragraph论文合辑

    A Hierarchical Approach for Generating Descriptive Image Paragraphs (CPVR 2017) Li Fei-Fei. 数据集地址: h ...

  6. Linux下获取arm的交叉编译工具链

    转载请注明文章:Linux下获取arm的交叉编译工具链 出处:多客博图 这里介绍,Linux下获取arm的交叉编译工具链,比如arm-linux-gnueabihf-gcc.arm-linux-gne ...

  7. C# 屏蔽Ctrl Alt Del 快捷键方法+屏蔽所有输入

    原文:C# 屏蔽Ctrl Alt Del 快捷键方法+屏蔽所有输入 Win32.cs /* * * FileCreate By Bluefire * Used To Import WindowsApi ...

  8. C#try catch块

    try..catch块的出现是为了异常处理. 格式为:try{...可能发生异常的代码...} catch{...对异常的处理...} finaly{...无论如何都会执行的代码..} 上面的只是一般 ...

  9. 浅谈网络I/O多路复用模型 select & poll & epoll

    http://blog.csdn.net/nk_test/article/details/50662946

  10. Qt 5.6.0 动态编译(VS2013 x86 target xp openssl icu webkit)

    经历了多次延期后,在3月16号,Qt发布了5.6.0版本(全面支持高DPI无疑是一个亮点),从5.6.0版本开始,Qt直接移除了webkit模块,让webengine作为其替代选择,不过webengi ...