【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 ...
随机推荐
- POJ2417 Baby-Step-Gaint-Step 算法
考虑一个问题:A^x%p=B,给定A,B,p,求x的最小非负整数解. 在p是质数的情况下,这个问题比較简单. A^x=B(mod P) (P is a Prime, A,B<P) Let m = ...
- BAPC2014 B&&HUNNU11582:Button Bashing(BFS)
题意: 给出n,m,代表微波炉有n个button,要求达到总时间为m 然后给出n个数.代表n个button能添加的时间,问最少几步,可以使得按出的总时间大于等于要求的时间,而且相差最小 输出最小的步数 ...
- Codeforces Round #281 (Div. 2) D. Vasya and Chess 博弈
D. Vasya and Chess Vasya decided to learn to play chess. Classic chess doesn't seem interesting to ...
- ubuntu下C程序的编辑、编译、运行
均以hello world程序为例 一.vim hello.c/hello.cpp 创建hello.c/hello.cpp文件,并进入vim界面 二.此时按键盘上的很多键均不会有任何反应,键入i,进入 ...
- Android系统升级那些事儿【转】
本文转载自:http://blog.csdn.net/chenyufei1013/article/details/12705719 版权声明:本文为博主原创文章,未经博主允许不得转载. 目录(?) ...
- bzoj5192: [Usaco2018 Feb]New Barns
不想写看zory大佬 #include<cstdio> #include<iostream> #include<cstring> #include<cstdl ...
- Android+Jquery Mobile学习系列(6)-个人信息设置
本节开始,进行代码的实战练习.我的这个App是管理保险客户信息的,数据采用Sqlite存储在本地手机上,第一次使用需要先登记自己的个人信息,这个功能非常简单,也无关紧要,我是拿这个练手,方便做后面复杂 ...
- openStack 主机流量计运行状态 随笔记录
root@ruiy-controller:~# ifconfigeth0 Link encap:Ethernet HWaddr 0c:c4:7a:0d:97:2c ine ...
- Java多线程技术-Volatile关键字解析
分析volatile关键字可以从这三个方面分析,什么是程序的原子性,什么是程序的可见性,什么是程序的有序性 什么是程序的原子性 以下语句那些是原子操作? public class ThreadCoun ...
- android view、viewgroup 事件响应拦截处理机制
文章中会用到部分网络资源,首先将原作者的链接附上. 但是还是会附上数量较大的关于此部分内容的自己的思考. ----------------------------------------------- ...