poj-3665 iCow(暴力吧)
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(暴力吧)的更多相关文章
- POJ - 3665 icow
Fatigued by the endless toils of farming, Farmer John has decided to try his hand in the MP3 player ...
- POJ - 3665 iCow(模拟)
题意:有N首歌曲,播放的顺序按照一定的规则,输出前T首被播放的歌的编号.规则如下: 1.每首歌有一个初始的等级r,每次都会播放当前所有歌曲中r最大的那首歌(若r最大的有多首,则播放编号最小的那首歌). ...
- poj 2363 Blocks(暴力)
题目链接:http://poj.org/problem?id=2363 思路分析:由于数据较小,采用暴力搜索法.假设对于矩形边长 1 <= a <= b <= c <= N; ...
- poj 1731 Orders(暴力)
题目链接:http://poj.org/problem?id=1731 思路分析:含有重复元素的全排列问题:元素个数为200个,采用暴力枚举法. 代码如下: #include <iostream ...
- POJ 2029 DP || 暴力
在大矩形中找一个小矩形 使小矩形包括的*最多 暴力或者DP 水题 暴力: #include "stdio.h" #include "string.h" int ...
- POJ 2912 Rochambeau(暴力)+【带权并查集】
<题目链接> 题目大意: n个人进行m轮剪刀石头布游戏(0<n<=500,0<=m<=2000),接下来m行形如x, y, ch的输入,ch='='表示x, y平局 ...
- POJ 2912 - Rochambeau - [暴力枚举+带权并查集]
题目链接:http://poj.org/problem?id=2912 Time Limit: 5000MS Memory Limit: 65536K Description N children a ...
- POJ 3414 Pots 暴力,bfs 难度:1
http://poj.org/problem?id=3414 记录瓶子状态,广度优先搜索即可 #include <cstdio> #include <cstring> #inc ...
- POJ 1971-Parallelogram Counting,暴力1063ms!
Parallelogram Counting 刚学hash还不会用,看到5000ms的时限于是想着暴力来一发应该可以过.以前做过类似的题,求平行四边形个数,好像是在CF上做的,但忘了时限是多少了,方法 ...
- POJ 1840 Eqs 暴力
Description Consider equations having the following form: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The ...
随机推荐
- [DDCTF 2019]homebrew event loop
0x00 知识点 逻辑漏洞: 异步处理导致可以先调用增加钻石,再调用计算价钱的.也就是先货后款. eval函数存在注入,可以通过#注释,我们可以传入路由action:eval#;arg1#arg2#a ...
- Ubuntu Hadoop使用过程中的一些技巧1
权限不足:打开有管理员权限的文件夹:sudo nautilus 输入密码即可进入最高权限的文件管理界面可以快速对文件进行修改删除操作 修改权限:chmod命令 chmod -R 777 文件 ...
- SQL基础教程(第2版)第4章 数据更新:4-1 数据的插入(INSERT)
第4章 数据更新:4-1 数据的插入(INSERT) ● 将列名和值用逗号隔开,分别括在()内,这种形式称为清单.● 对表中所有列进行INSERT操作时可以省略表名后的列清单.● 插入NULL时需要在 ...
- MVC——再探MVC——增删查改
MVC 是我大学学的比较弱的,甚至不懂原理.(那时候都在准备蓝桥杯 软件杯比赛.) 在重新学 肯定要学MVC 现在知道了为什么叫MVC了 MVC是怎么工作的 MVC 是一个设计模式 控制器(Cont ...
- Ubuntu编译protobuf
个人博客地址:http://www.bearoom.xyz/2019/08/24/ubunt-protobuf/ 因为编译了tensorflow C++的版本,然后提示protobuf的版本不对应引起 ...
- List中常用的linq操作
[Serializable] public class Product { public Product() { } public Product(string id,string pname,int ...
- Aras Innovator客户端批量下载关联文件
<button onclick="btnDownload();" id="downfilebtn">批量下载关联文件</button> ...
- SpringSecurity过滤器顺序
https://blog.csdn.net/qq_35720307/article/details/97656608 org.springframework.security.config.annot ...
- 01 语言基础+高级:1-4 接口与多态_day09【继承、super、this、抽象类】
day09[继承.super.this.抽象类] 三大特性——继承方法重写super关键字this关键字抽象类 教学目标能够解释类名作为参数和返回值类型能够写出类的继承格式能够说出继承的特点能够说出子 ...
- 查看jks文件中的签名
1. 打开CMD命令行进入本机安装的jdk或jre下的bin目录. 2. 下来看图 keytool -list -v -keystore C:\Users\Administrator\Desktop\ ...