【Codeforces Round #519 by Botan Investments A】 Elections
【链接】 我是链接,点我呀:)
【题意】
【题解】
枚举k
那么另外一个人的得票就是n*k-sum(ai)
找到最小的满足n*k-sum(ai)>sum(ai)的k就ok了
【代码】
#include <bits/stdc++.h>
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
using namespace std;
const int N = 100;
int n;
int a[N+10];
int main()
{
cin >> n;
rep1(i,1,n) cin >> a[i];
int st = a[1];
for (int i = 2;i <= n;i++) st = max(st,a[i]);
int sum = 0;
rep1(i,1,n) sum+=a[i];
for (int i = st;;i++){
if (i*n>2*sum){
cout<<i<<endl;
return 0;
}
}
return 0;
}
【Codeforces Round #519 by Botan Investments A】 Elections的更多相关文章
- 【Codeforces Round #519 by Botan Investments E】Train Hard, Win Easy
[链接] 我是链接,点我呀:) [题意] [题解] 设每个人做第一题.第二题的分数分别为x,y 我们先假设没有仇视关系. 即每两个人都能进行一次训练. 那么 对于第i个人. 考虑第j个人对它的贡献 如 ...
- 【 Codeforces Round #519 by Botan Investments B】Lost Array
[链接] 我是链接,点我呀:) [题意] [题解] 枚举k 不难根据a得到x[0..k-1] 然后再根据a[k+1..n]来验证一下得到的x是否正确就好. [代码] #include <bits ...
- 【Codeforces Round #519 by Botan Investments C】 Smallest Word
[链接] 我是链接,点我呀:) [题意] [题解] 模拟了一两下.. 然后发现. 对于每一个前缀. 组成的新的最小字典序的字符串 要么是s[i]+reverse(前i-1个字符经过操作形成的最大字典序 ...
- 【Codeforces Round #519 by Botan Investments D】Mysterious Crime
[链接] 我是链接,点我呀:) [题意] 相当于问你这m个数组的任意长度公共子串的个数 [题解] 枚举第1个数组以i为起点的子串. 假设i..j是以i开头的子串能匹配的最长的长度. (这个j可以给2. ...
- Codeforces Round #519 by Botan Investments
Codeforces Round #519 by Botan Investments #include<bits/stdc++.h> #include<iostream> #i ...
- Codeforces Round #519 by Botan Investments(前五题题解)
开个新号打打codeforces(以前那号玩废了),结果就遇到了这么难一套.touristD题用了map,被卡掉了(其实是对cf的评测机过分自信),G题没过, 700多行代码,码力惊人.关键是这次to ...
- Codeforces Round #519 by Botan Investments F. Make It One
https://codeforces.com/contest/1043/problem/F 题意 给你n个数,求一个最小集合,这个集合里面数的最大公因数等于1 1<=n<=3e5 1< ...
- Codeforces Round #519 by Botan Investments翻车记
A:枚举答案即可.注意答案最大可达201,因为这个wa了一发瞬间爆炸. #include<iostream> #include<cstdio> #include<cmat ...
- 【Codeforces Round #519】
A:https://www.cnblogs.com/myx12345/p/9872082.html B:https://www.cnblogs.com/myx12345/p/9872124.html ...
随机推荐
- ASP.NET MVC脚本及样式压缩
现在我用ASP.NET MVC4.0,发现它自带有脚本和样式压缩功能.不知道以前的版本有木有,没有深究.太棒了!以前我们还辛辛苦苦自己搞了一个压缩的东西.这再次说明,平庸程序员如我辈,应该把时间和精力 ...
- App/Activity/Screen Orientation
测试android屏幕方向的小Demo 1.首先我们在values下面新建文件arrays.xml(用来在下拉列表中显示) <?xml version="1.0" encod ...
- 【BZOJ 1370】 团伙
[题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1370 [算法] 并查集 + 拆点 [代码] #include<bits/std ...
- logistic regression二分类算法推导
- 网上订餐系统的SQL SERVER 2005数据库连接
- 昂贵的聘礼(Dijkstra)
http://poj.org/problem?id=1062 每个物品看成一个节点,酋长的允诺也看作一个物品, 如果一个物品加上金币可以交换另一个物品,则这两个节点之间有边,权值为金币数,求第一个节点 ...
- 使用 Polyfill 而不再是 bable 来实践js新特性
现状 我们想要用ES6 语法来写 JavaScript.然而由于我们需要兼容老版本的浏览器,那些浏览器不支持 ES6,我们需要解决这个问题. 有一个标准的做法是:写 ES6 代码 → 将所有代码编译成 ...
- com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'admin' for key 'UK_dgxl7aijrr4hq8314exhw407s'
严重: Servlet.service() for servlet [spring-mvc] in context with path [/learn] threw exception [Reques ...
- 在mac上截屏的几种方式
方法 1: 对屏幕的一部分进行截图 按下Command+Shift+4 方法 2: 对整个屏幕进行截图 按下Command+Shift+3 方法 3: 把截图保存到粘贴板 按下Command+ ...
- JS排序之快速排序
JS排序之快速排序 一个数组中的数据,选择索引为(2/数组长度)的那个数据作为基数,数组中的其他数据与它对比,比它数值小的放在做数组,比它数值大的放在右数组,最后组合 左数组+基数+右数组,其中,左数 ...