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. Java 阅读TXT文件

    public class GenCategoryAttrItemHandler { private final static String INPUT_FILE_PATH = "input/ ...

  2. sql 1=1

    大多数时候是为了sql拼写方便而加的条件从执行任务来看,不影响性能  

  3. How to manipulate pixels on a bitmap by scanline property(Ma Xiaoguang and Ma Xiaoming)

    We have been developing image processing software for above 14 years with old versions of Delphi, su ...

  4. 海康sdk

    package com.hikvision.artemis.sdk.util; import java.util.Collections; import java.util.Iterator; imp ...

  5. painter半透明的 底层窗口全透明背景

  6. einsum:爱因斯坦求和约定

    在Tensorflow.Numpy和PyTorch中都提供了使用einsum的api,einsum是一种能够简洁表示点积.外积.转置.矩阵-向量乘法.矩阵-矩阵乘法等运算的领域特定语言.在Tensor ...

  7. How to Capture the Integer-Divide-By-Zero Error in C++(提前定义信号)

    How to Capture the Integer-Divide-By-Zero Error in C++? MANUAL CAPTURE The simple and straightforwar ...

  8. IntelliJ IDEA Maven工程保证JDK版本不变

    创建maven项目后修改pom文件idea会默认将jdk版本调回到1.5,这是因为没有在pom里面设置项目的jdk版本 解决方法: 在pom文件中设定jdk版本即可,以下这种写法会自动更新idea中的 ...

  9. 使用C#的HttpWebRequest模拟登陆访问人人网

    使用任何语言做模拟登陆或者抓取访问页面,无外乎以下思路: 第一 启用一个web访问会话方法或者实例化一个web访问类,如.net中的HttpWebRequest:第二 模拟POST或者GET方式提交的 ...

  10. javaweb各种框架组合案例(三):maven+spring+springMVC+hibernate

    1.hibernate译为"越冬",指的是给java程序员带来春天,因为java程序员无需再关心各种sql了: 2.hibernate通过java类生成数据库表,通过操作对象来映射 ...