http://poj.org/problem?id=3665

题目描述

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.

输入描述:

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

输出描述:

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

输入


输出


说明

The iCow contains 3 songs, with ratings 10, 8, and 11, respectively. You must determine the first 4 songs to be played.
The ratings before each song played are:
R1 R2 R3
10 8 11 -> play #3 11/2 = 5, leftover = 1
16 13 0 -> play #1 16/2 = 8
0 21 8 -> play #2 21/2 = 10, leftover = 1
11 0 18 -> play #3 ...

刚开始以为要用优先队列,结果越写越麻烦,最后写乱了,wa了,还不如直接暴力做

 #include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <math.h> #define INF 0x3f3f3f3f
#define MAXN 1005
const int mod = 1e9 + ; using namespace std; int d[MAXN]; int main()
{
int N, K;
cin >> N >> K; for (int i = ; i <= N; i++)
scanf("%d", &d[i]); while (K--) {
int maxx = -;
int flag = ;
for (int i = ; i <= N; i++)
if (d[i] > maxx)
maxx = d[i], flag = i;
printf("%d\n", flag);
int temp = d[flag] / (N - );
if (temp) {
for (int i = ; i <= N; i++) {
if (i != flag)
d[i] += temp;
}
}
temp = d[flag] % (N - );
d[flag] = ;
if (temp) {
for (int i = ; i <= N && temp; i++) {
if (i != flag)
d[i]++, temp--;
}
}
} return ;
}

poj-3665 iCow(暴力吧)的更多相关文章

  1. POJ - 3665 icow

    Fatigued by the endless toils of farming, Farmer John has decided to try his hand in the MP3 player ...

  2. POJ - 3665 iCow(模拟)

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

  3. poj 2363 Blocks(暴力)

    题目链接:http://poj.org/problem?id=2363 思路分析:由于数据较小,采用暴力搜索法.假设对于矩形边长 1 <= a <= b <= c <= N; ...

  4. poj 1731 Orders(暴力)

    题目链接:http://poj.org/problem?id=1731 思路分析:含有重复元素的全排列问题:元素个数为200个,采用暴力枚举法. 代码如下: #include <iostream ...

  5. POJ 2029 DP || 暴力

    在大矩形中找一个小矩形 使小矩形包括的*最多 暴力或者DP  水题 暴力: #include "stdio.h" #include "string.h" int ...

  6. POJ 2912 Rochambeau(暴力)+【带权并查集】

    <题目链接> 题目大意: n个人进行m轮剪刀石头布游戏(0<n<=500,0<=m<=2000),接下来m行形如x, y, ch的输入,ch='='表示x, y平局 ...

  7. POJ 2912 - Rochambeau - [暴力枚举+带权并查集]

    题目链接:http://poj.org/problem?id=2912 Time Limit: 5000MS Memory Limit: 65536K Description N children a ...

  8. POJ 3414 Pots 暴力,bfs 难度:1

    http://poj.org/problem?id=3414 记录瓶子状态,广度优先搜索即可 #include <cstdio> #include <cstring> #inc ...

  9. POJ 1971-Parallelogram Counting,暴力1063ms!

    Parallelogram Counting 刚学hash还不会用,看到5000ms的时限于是想着暴力来一发应该可以过.以前做过类似的题,求平行四边形个数,好像是在CF上做的,但忘了时限是多少了,方法 ...

  10. POJ 1840 Eqs 暴力

      Description Consider equations having the following form: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The ...

随机推荐

  1. 从AppleWatch4发布后对手股价大跌看可穿戴市场未来

    万众瞩目的苹果秋季发布会终于落下了帷幕,这场发布会既有惊喜,也有遗憾.遗憾的是新款iPad Pro.廉价版Macbook air没有亮相.iPhone系列价格较贵等,惊喜的则是iPhone的处理器依然 ...

  2. C#调用C++系列一:简单传值

    因为去实习的时候有一个小任务是C#想调用C++ opencv实现的一些处理,那我主要的想法就是将C++实现的OpenCV处理封装成dll库供C#调用,这里面还会涉及到一些托管和非托管的概念,我暂时的做 ...

  3. zabbix获取到的数值大于1000之后自动转换成1k

    问题:zabbix在取到的值很大时会自动变成K,M,G 解决方法: 1.修改/var/www/html/zabbix/include/func.inc.php文件(这个文件不一定在这,自己find找下 ...

  4. MySQL 插入 中文数据乱码解决

    问题描述: 1.在命令行中进行插入,没有问题.但是显示存在部分乱码 2.在JDBC中插入成功.中文是直接以“??”形式显示. 通过Navicat客户端查看 与在网页中看到的一一致,说明读取没有问题,问 ...

  5. zTree & ckeditor &ValidateCode.jar 使用个人心得总结

    zTree:依靠 jQuery 实现的多功能 “树插件”. 使用时只需要将下载的压缩包接用,复制里边的css 和 js 到指定目录即可. 如图所示: 在zTree的官网可以找到各种类型树的示例: 地址 ...

  6. 牛逼了,用Python破解wifi密码

    Python真的是无所不能,原因就是因为Python有数目庞大的库,无数的现成的轮子,让你做很多很多应用都非常方便.wifi跟我们的生活息息相关,无处不在.今天从WiFi连接的原理,再结合代码为大家详 ...

  7. mysql出现 too many connections

    出现这个问题的原因网上大致都是说这三种 1.慢sql 2.大量持久性的连接 3.程序没有及时关闭连接 解决方式 mysql -u 账号 -p 输入密码 show processlist; kill掉s ...

  8. vue的选项卡功能

    选项卡:点击不同的按钮会显示不同的内容 <!DOCTYPE html> <html lang="en"> <head> <meta cha ...

  9. usr/sbin/inetd

    root 4 0.0 1344 1204? S 17:09 0:10 /usr/sbin/inetd 运行 Internet 超级 服务器,它负责监听 Internet sockets 上的连接,并调 ...

  10. Java线程——线程之间的几点重要说明

    在Java中,可以通过配合调用Object对象的wait()方法和notify()方法或notifyAll()方法来实现线程间的通信.在线程中调用wait()方法,将阻塞等待其他线程的通知(其他线程调 ...