coderforce 574A Bear and Elections
来源:互联网 发布:windows 10 安装office 编辑:程序博客网 时间:2024/05/16 17:34
题意:有n个数a1,a2,a3,a4....,一次操作可以从将ai减去一个值d,然后第一个数变为a1+d,那么这次操作的代价为d,求使a1大于所有数的最小代价。
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;const int maxm=1e2+10;int a[maxm];int main(){ int n; while(scanf("%d",&n)!=EOF) { for(int i=0;i<n;i++) { scanf("%d",&a[i]); } int x=a[0]; sort(a+1,a+n); while(a[0]<=a[n-1]) { a[0]++; a[n-1]--; sort(a+1,a+n); } printf("%d\n",a[0]-x); } return 0;}
1 0
- coderforce 574A Bear and Elections
- A. Bear and Elections
- CodeForces 574A - Bear and Elections
- Codeforces 574 A. Bear and Elections
- Codeforces 574 A. Bear and Elections
- Codeforces Round #318 574A Bear and Elections(优先队列)
- Codeforces Round #318 A. Bear and Elections
- coderforce 573A Bear and Poker
- Bear and Elections
- Bear and Elections
- Bear and Elections CodeForces
- 模拟赛#1补题 CodeForces 574A Bear and Elections(模拟+)
- Codeforces Round #318 (Div. 2) A. Bear and Elections
- Codeforces Round #318 574C Bear and Elections(脑洞)
- CF574A Bear and Elections 暴力即可
- CF#318-Bear and Elections-贪心暴力
- 在青岛穷游打的cf codeforces Round #318 (Div. 2) A.Bear and Elections
- Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 2) A. Bear and Elections(优先队列)
- 【Android】Android中使用JNI调用底层C++代码
- 了解echo命令语法及应用
- Android自定义EditText实现手机号码和银行卡号自动分隔
- android.app.ActionBar $LayoutParams cannot be cast to android.widget.FrameLayout$LayoutParams
- 0002 C++字符串的详解
- coderforce 574A Bear and Elections
- iOS学习日志
- aidl远程调用其他应用服务
- React Native 环境配置
- 内亚的三重面相
- iOS开发——keychain的使用
- netty
- 搭建高可用mongodb集群(一)——配置mongodb
- 默认初始ViewPager切换到指定页面不需要滑动过程