码迷,mamicode.com
首页 > 其他好文 > 详细

BaLaBaLa

时间:2015-08-12 21:34:46      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;

struct node
{
friend bool operator< (node n1, node n2)
{
if(n1.Time==n2.Time) return n2.ID<n1.ID;
return n2.Time<n1.Time;
}
int ID;
int Time;
};

int n,m;

int main()
{
while(~scanf("%d%d",&n,&m)){
priority_queue<node> Q;
for(int i=1;i<=n;i++)
{
node k;
k.ID=i;
k.Time=0;
Q.push(k);
}
for(int i=1;i<=m;i++)
{
int time;
scanf("%d",&time);
node k=Q.top();Q.pop();
if(i==m)
{
printf("%d\n",k.ID);
}
else
{
node h;
h.ID=k.ID;
h.Time=k.Time+time;
Q.push(h);
}
}
}
return 0;
}

BaLaBaLa

标签:

原文地址:http://www.cnblogs.com/zufezzt/p/4725424.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!