• hust 1042 iCow


    题目描述

    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 R_i (1 <= R_i <= 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., R_1, R_2, 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: R_i

    输出

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

    样例输入

    3 4
    10
    8
    11
    

    样例输出

    3
    1
    2
    3

    一直以为这是道难题,于是没有敢做,今天终于鼓起勇气看了看题目,可是英文好难懂,看来半天,这种题目太没有意思了,好吧!可能是我英语太差了,
    题意就是每次选出值最大的点,然后把它平分给余下的n-1个,多余的从艺开始分,直到分完,然后这个点变为0;没有给数据范围,还以为要用特殊数据结构,结果是道水题,根本不用管当最大之一样的时候,每次都从编号为1的查找,最大的就是编号最小的,
     1 #include<map>
     2 #include<set>
     3 #include<queue>
     4 #include<cmath>
     5 #include<vector>
     6 #include<cstdio>
     7 #include<string>
     8 #include<cstring>
     9 #include<cstdlib>
    10 #include<iostream>
    11 #include<algorithm>
    12 #define  inf 0x0f0f0f0f
    13 
    14 using namespace std;
    15 
    16 const double pi=acos(-1.0);
    17 const double eps=1e-8;
    18 typedef pair<int,int>pii;
    19 
    20 int a[100000];
    21 
    22 int main()
    23 {
    24     freopen("in.txt","r",stdin);
    25 
    26     int n,t;
    27     while (scanf("%d%d",&n,&t)!=EOF)
    28     {
    29         int maxx=-1,id;
    30         for (int i=1;i<=n;i++)
    31         {
    32             scanf("%d",&a[i]);
    33         }
    34         while (t--)
    35         {
    36             maxx=-1;
    37             for (int i=1;i<=n;i++)
    38             {
    39                 if (maxx<a[i])
    40                 {
    41                     maxx=a[i];
    42                     id=i;
    43                 }
    44             }
    45             printf("%d
    ",id);
    46             int num=maxx/(n-1);
    47             int mm=maxx%(n-1);
    48             for (int i=1;i<=n;i++)
    49             if (i!=id)
    50             {
    51                 a[i]+=num;
    52                 if (mm)
    53                 {
    54                     a[i]+=1;
    55                     mm--;
    56                 }
    57             }
    58             a[id]=0;
    59         }
    60     }
    61     fclose(stdin);
    62     return 0;
    63 }
    至少做到我努力了
  • 相关阅读:
    NumPy 基本语法汇总
    python自动化操作——excel刷新数据并截图发送微信
    datefram学习(持续更新)
    python——imap邮件自动下载附件和邮件正文
    ERP笔记1系统环境
    ERP笔记2善用SVN对系统环境进行配置和组织
    ERP笔记4SVN目录的权限分配
    ERP笔记3数据库的版本化
    DBCC CHECKCATALOG 错误
    非常棒的放礼花的源程序
  • 原文地址:https://www.cnblogs.com/chensunrise/p/3678225.html
Copyright © 2020-2023  润新知