【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) = ... 
随机推荐
- C# 正则表达式 和 JAVA表达式是想通的
			正则表达式语法 也许有人会说,现在需要正则表达式去验证什么的话,直接在网上找不久一大片吗?还需要学什么啊! 是的,现在在网上找确实是一找一大片,但是,有时候我们也遇到这样的情况,就是我们在网上找的复制 ... 
- Integer应该用==还是equals
			问题引出:“Integer应该用==还是equals” 讨论这个问题之前我们先放一段代码 public static void main(String[] args) { Integer a1 = 2 ... 
- java的封箱和拆箱
			1.基本概念 字节的单位:byte.位的单位:bit,1byte=8bit 2.8种基本数据类型 4种整型,2种浮点类型,1种用于表示Unicode编码的字符单元的字符类型和1种用于表示真值的bool ... 
- css样式变  及实际用法
			<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Con ... 
- 笔记 — 动画效果(Css3)
			/** * animation-name: 调用 @keyframes 所定义的动画 * animation-duration: 动画周期所花费的时间长度 * animation-timing-fun ... 
- Android 使用SQLite存储以及读取Drawable对象
			在进行Android开发过程中,我们经常会接触到Drawable对象,那么,若要使用数据库来进行存储及读取,该如何实现? 一.存储 //第一步,将Drawable对象转化为Bitmap对象 Bitma ... 
- Java code List Map, HashMap, JSON parser snippet
			package com.newegg.ec.solr.eventsalestoreservice.tuple; import kafka.message.MessageAndMetadata; pub ... 
- SAP computer之architecture
			Simple-As-Possible computer introduces all the cruicial ideas behind computer operation without bury ... 
- 黑客常用dos命令
			http://blog.csdn.net/CSDN___LYY/article/details/77802438 
- AI:IPPR的模式生成-学习/训练方式(基本结构)
			前言: 一个完备的模式识别系统,必然包含一个模式识别模型,此外还要附加一个评价模型,以及为了构建识别模型而构建的学习模型,并选择在学习模型中使用的学习方法. 否则 w=w 这样,)那样 ... 
