【Codeforces 996B】World Cup
【链接】 我是链接,点我呀:)
【题意】
【题解】
你可以找出来a[i]里面的最小值mi,显然是这个数字最可能先变成0,但还不确定.
然后用mi/n得到你最少需要走多少圈才能让那个mi变成"只差一圈"就变成0.
那么把所有的a[i]都减去mi/n*n
然后再手动地模拟一圈(显然再模拟一圈就能让某个a[i]变成0了,即让那个mi变成0
但是有例外
比如说
6 5 7 8 9 10
这6个数字
mi=5
5/6=0
所以一开始a[i]不用减去任何数字.
但是你第一次遇到5的时候,5只变成了4.还没有变成0.
所以还得再模拟一圈.
这种情况,就模拟两圈就ok了。
综上,模拟两圈一定能得到a[i]=0的.
【代码】
#include <bits/stdc++.h>
#define rep1(i,a,b) for (int i = a;i <= b;i++)
using namespace std;
const int N = 1e5;
int n;
int a[N+10],mi;
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin >> n;
rep1(i,1,n) cin >> a[i];
mi = a[1];rep1(i,1,n) mi = min(mi,a[i]);
int quan = mi/n;
rep1(i,1,n) a[i] -= quan*n;
int past = 0;
rep1(i,1,n){
if (a[i]-past<=0){
cout<<i<<endl;
return 0;
}
past++;
}
rep1(i,1,n){
if (a[i]-past<=0){
cout<<i<<endl;
return 0;
}
past++;
}
return 0;
}
【Codeforces 996B】World Cup的更多相关文章
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【23.33%】【codeforces 557B】Pasha and Tea
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【21.58%】【codeforces 746D】Green and Black Tea
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【codeforces 707E】Garlands
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...
- 【codeforces 707C】Pythagorean Triples
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...
- 【codeforces 709D】Recover the String
[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...
- 【codeforces 709B】Checkpoints
[题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...
- 【codeforces 709C】Letters Cyclic Shift
[题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...
- 【Codeforces 429D】 Tricky Function
[题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...
随机推荐
- Extjs grid 某列点击弹窗
{ header : "单号", tooltip : '单号', dataIndex : 'transportCode', width : 130, sortable : true ...
- HDU 5533/ 2015长春区域 G.Dancing Stars on Me 暴力
Dancing Stars on Me Problem Description The sky was brushed clean by the wind and the stars were col ...
- bzoj 1093 [ ZJOI 2007 ] 最大半连通子图 —— 拓扑+DP
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1093 先缩点,然后就是找最长链,DP一下即可: 注意缩点后的重边!会导致重复计算答案. 代码 ...
- Java项目打包发布
Java项目打包发布 如果只想发布为一个可执行的jar包,使用eclipse的Export功能就可以了 使用eclipse的Export功能,将项目中的所有package打包为一个pet.jar文件, ...
- The Moronic Cowmpouter(负进位制转换)
http://poj.org/problem?id=3191 题意:将一个整型的十进制整数转化为-2进制整数. #include <stdio.h> #include <algori ...
- Gym - 101981D The 2018 ICPC Asia Nanjing Regional Contest D.Country Meow 最小球覆盖
题面 题意:给你100个三维空间里的点,让你求一个点,使得他到所有点距离最大的值最小,也就是让你找一个最小的球覆盖掉这n个点 题解:红书模板题,这题也因为数据小,精度也不高,所以也可以用随机算法,模拟 ...
- 通过学习Date和Calendar时写的日历
package com.etc.util; import java.util.Calendar; import java.util.Scanner; public class Calendar2 { ...
- word中选择嵌入式时图片被遮住,只显示小部分的解决方法
选中图片,点击如下 选择 行距选项 将行距改为单位行距即可.
- 【Oracle】解决oracle sqlplus 中上下左右backspace不能用
一. 解决输入 BACKSPACE 键变成 ^h 的问题 #su - oracle $stty erase ^h. 要永久生效,可以加入到用户环境配置文件.bash_profile中(vi .ba ...
- PHP获得文件的大小并转换格式
利用filesize($filename)函数获得一个文件的大小 参数$filename为文件的绝对路径,返回的值是文件的大小字节数. 文件较大的时候看起来不方便,下面是一个格式化方法 functio ...