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. fzu-1753 Another Easy Problem-高速求N!多少个月p

    它计算每个C(N,M)什么号码乘以像.... #include <iostream> #include<stdio.h> #include<vector> #inc ...

  2. HDU-3839-Ancient Messages(DFS)

    Problem Description In order to understand early civilizations, archaeologists often study texts wri ...

  3. WPF 自定义图片剪切器 - 头像剪切(扩展与完善、实时截图)

    原文:WPF 自定义图片剪切器 - 头像剪切(扩展与完善.实时截图) 一.说明:上一次写的"WPF 自定义图片剪切器 - 头像剪切.你懂得"存在明显的缺陷,由于篇幅较长.重新写了一 ...

  4. Android零基础入门第27节:正确使用padding和margin

    原文:Android零基础入门第27节:正确使用padding和margin 前面两期我们学习了LinearLayout线性布局的方向.填充模型.权重和对齐,那么本期我们来学习LinearLayout ...

  5. WPF 设置只能运行一个实例

    codereview上的帖子 https://codereview.stackexchange.com/questions/20871/single-instance-wpf-application ...

  6. 简单图标转xaml代码

    工具 PhotoShopCC(2017) Blend 2017 原图 步骤 1,使用钢笔工具勾勒出大致路径 2,将工作路径转为形状路径 3,图层右键->复制SVG <svg xmlns=& ...

  7. Elasticsearch教程(一)简介与安装

    简单概念 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口.Elasticsearch是用Java开发的,并作为 ...

  8. ASP.NET vNext 微笔记

    关心 ASP.NET vNext 的人可能已经读过相关文章,例如:ASP.NET vNext @ 2014.那么,你可能已经知道,ASP.NET vNext 摆脱了 System.Web.DLL,把 ...

  9. 解决SpringBoot多模块发布时99%的问题?SpringBoot发布的8个原则和4个问题的解决方案

    如果使用 SpringBoot 多模块发布到外部 Tomcat,可能会遇到各种各样的问题.本文归纳了以下 8 个原则和发布时经常出现的 4 个问题的解决方案,掌握了这些原则和解决方案,几乎可以解决绝大 ...

  10. 运维不仅仅是Linux,居然还要知道这么多?

    摘要: 运维不仅仅是懂Linux就行,因为还有一大部分的Windows运维,向windows运维人员致敬.当然我们这篇文章不是说运维除了懂Linux,还要懂Windows,而是涉及运维的其他方方面面. ...