比赛 |
20170919普及组 |
评测结果 |
AWWWWWWWWW |
题目名称 |
iCow播放器 |
最终得分 |
10 |
用户昵称 |
Samle |
运行时间 |
0.004 s |
代码语言 |
C++ |
内存使用 |
0.03 MiB |
提交时间 |
2017-09-19 20:52:26 |
显示代码纯文本
#include<map>
#include<queue>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define R register
#define ll long long
#define inf 707406378
inline void in(int &x) {
static int ch; static bool flag;
for(flag = false,ch = getchar();ch < '0'||ch > '9';ch = getchar()) flag |= ch == '-';
for(x = 0;isdigit(ch);ch = getchar()) x = (x<<1) + (x<<3) + ch - '0';
x = flag ? -x : x;
}
inline void write(int x){
if(x<0) putchar('-'),x=-x;
if(x>9) write(x/10);
putchar(x%10+'0');
}
int n,T;
int heap[1005];
int k[1005][3],kn;
int cnt[1005];
inline void up(int i){
R int j=(i>>1);
while(j && heap[i]>heap[j]){
R int t=heap[i];
heap[i]=heap[j],heap[j]=t;
t=cnt[i];
cnt[i]=cnt[j],cnt[j]=t;
i=j,j=(i>>1);
}
}
inline void insert(int i,int j){
heap[++n]=i,cnt[n]=j;
up(n);
}
inline void down(int i){
R int j=(i<<1);
if(j+1<=n && heap[j+1]>heap[j])j++;
while(j<=n && heap[j]>heap[i]){
R int t=heap[i];
heap[i]=heap[j],heap[j]=t;
t=cnt[i];
cnt[i]=cnt[j],cnt[j]=t;
i=j,j=(i<<1);
if(j+1<=n && heap[j+1]>heap[j])j++;
}
}
inline void del(int i){
heap[i]=heap[n];
cnt[i]=cnt[n--];
up(i),down(i);
}
inline void build(){
for(int i=1;i<=n;++i)in(heap[i]),cnt[i]=i;
for(int i=n/2;i;--i)down(i);
}
inline int dy(){
freopen("icow.in","r",stdin);
freopen("icow.out","w",stdout);
in(n),in(T);
build();
while(T--){
R int t=heap[1],pos=cnt[1];
printf("%d\n",pos);
del(1);
R int inv=t/(n-1),res;
if(inv*t-inv<t)res=inv*t-inv;
for(int i=1;i<=n;++i)heap[i]+=inv;
for(int i=1;i<=res;++i)
k[++kn][0]=heap[1],k[kn][1]=cnt[1],del(1);
for(int i=1;i<=res;++i)insert(k[kn][0]+1,k[kn][1]);
insert(t,pos);
kn=0;
}
}
int QAQ = dy();
int main(){;}