Fatigued by the endless toils of farming, Farmer John has decided to try his hand in the MP3 player market with the new iCow. It is an MP3 player that stores N songs (1 ≤ N ≤ 1,000) indexed 1 through N that plays songs in a "shuffled" order, as determined by Farmer John's own algorithm:

  • Each song i has an initial rating Ri (1 ≤ Ri ≤ 10,000).
  • The next song to be played is always the one with the highest rating (or, if two or more are tied, the highest rated song with the lowest index is chosen).
  • After being played, a song's rating is set to zero, and its rating points are distributed evenly among the other N-1 songs.
  • If the rating points cannot be distributed evenly (i.e., they are not divisible by N-1), then the extra points are parceled out one at a time to the first songs on the list (i.e., R1 , R2 , etc. -- but not the played song) until no more extra points remain.

This process is repeated with the new ratings after the next song is played.

Determine the first T songs (1 ≤ T ≤ 1000) that are played by the iCow.

Input

* Line 1: Two space-separated integers: N and T
* Lines 2..N+1: Line i+1 contains a single integer: Ri

Output

* Lines 1..T: Line i contains a single integer that is the i-th song that the iCow plays.

Sample Input

3 4
10
8
11

Sample Output

3
1
2
3

这题的坑在于红字部分的理解,无法平均分的point从第一个开始,每个cow分一个,直到分完。
挺难读的 :(
 1 #include<cstdio>
2 #define Max 1111
3 int cow[Max];
4 int main()
5 {
6 int n,t;
7 int max=-1,maxi;
8 int left=0,add=0;
9 while(~scanf("%d %d",&n,&t))
10 {
11 for(int i=1;i<=n;i++)
12 scanf("%d",&cow[i]);
13 if(n==1) //这个条件不加也能过
14 { //但题目上n取值明明可以等于1
15 while(t--) //不知道是题意我没有理解透,还是数据水
16 printf("1\n");
17 }
18 else
19 {
20 for(int k=0;k<t;k++)
21 {
22 for(int i=1;i<=n;i++)
23 {
24 if(max<cow[i])
25 {
26 maxi=i;
27 max=cow[i];
28 }
29 }
30 printf("%d\n",maxi);
31 left=max%(n-1);
32 add=max/(n-1);
33 cow[maxi]=0;
34 max=-1;
35 for(int j=1;j<=n;j++)
36 {
37 if(j==maxi)continue;
38 if(left)
39 {
40 cow[j]++;
41 left--;
42 }
43 cow[j]+=add;
44 }
45 }
46 }
47 }
48 return 0;
49 }

 

POJ - 3665 icow的更多相关文章

  1. POJ - 3665 iCow(模拟)

    题意:有N首歌曲,播放的顺序按照一定的规则,输出前T首被播放的歌的编号.规则如下: 1.每首歌有一个初始的等级r,每次都会播放当前所有歌曲中r最大的那首歌(若r最大的有多首,则播放编号最小的那首歌). ...

  2. POJ 3665 模拟

    按照题意模拟就OK了 //By SiriusRen #include <cstdio> #include <cstring> #include <algorithm> ...

  3. poj-3665 iCow(暴力吧)

    http://poj.org/problem?id=3665 题目描述 Fatigued by the endless toils of farming, Farmer John has decide ...

  4. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  5. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  6. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  7. POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Descr ...

  8. POJ 3254. Corn Fields 状态压缩DP (入门级)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Descr ...

  9. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

随机推荐

  1. hive窗口函数/分析函数详细剖析

    hive窗口函数/分析函数 在sql中有一类函数叫做聚合函数,例如sum().avg().max()等等,这类函数可以将多行数据按照规则聚集为一行,一般来讲聚集后的行数是要少于聚集前的行数的.但是有时 ...

  2. vue href url地址写法

  3. [noip模拟]分组行动

    题目描述 最近,木木中学要举行一年一度的辩论赛了,我们活泼开朗乐观向上不寂寞不生病不挂科天天回家吃饭的新时代好少年--飞飞,自然是热情参与咯!辩论嘛,就有正方和反方两个组,这是一个传统项目,所以,包括 ...

  4. scrapy框架的中间件

    中间件的使用 作用:拦截所有的请求和响应 拦截请求:process_request拦截正常的请求,process_exception拦截异常的请求 篡改请求的头信息 def process_reque ...

  5. 微信小程序腾讯地图SDK使用方法

    一.本篇文章主要知识点有以下几种: 1.授权当前位置 2.map组件的使用 3.腾讯地图逆地址解析 4.坐标系的转化 二.效果如下: 三.WXML代码 <map id="map&quo ...

  6. winform 扫码识别二维码

    因为公司业务需求,需要在Windows系统下调用摄像头识别二维码需求,就有了这个功能. 我根据网上网友提供的一些资料,自己整合应用到项目中,效果还不错(就是感觉像素不是太好) 现在将调用摄像头+识别二 ...

  7. vue3.0 composition API

    一.Setup函数 1.创建时间:组件创建之前被调用,优先与created被调用,this指向的实例为window,created所指向的实例为proxy 2.this指向:不会指向组件实例 3.参数 ...

  8. 一文搞定全场景K3s离线安装

    作者简介 王海龙,Rancher中国社区技术经理,负责Rancher中国技术社区的维护和运营.拥有6年的云计算领域经验,经历了OpenStack到Kubernetes的技术变革,无论底层操作系统Lin ...

  9. Maven 基础详解

    一.编写pom.xml文件     Maven项目的核心是pom.xml.POM(Project Object Model,项目对象模型)定义了项目的基本信息,用于描述项目如何构建,声明项目依赖等等. ...

  10. Golang 单元测试:有哪些误区和实践?

    https://mp.weixin.qq.com/s/k8WNWpCIVl4xTmP3TQ_gxQ