记录编号 |
367596 |
评测结果 |
AAAAAAAAAAAAAAAAAAAA |
题目名称 |
[NOIP 2016]蚯蚓 |
最终得分 |
100 |
用户昵称 |
cstdio |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
1.789 s |
提交时间 |
2017-01-31 19:28:33 |
内存使用 |
0.70 MiB |
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<vector>
using namespace std;
typedef long long LL;
const int SIZEN=100010;
const int SIZEM=7100005;
int N,M;//N只,M时间
int Q,U,V,T;//p=u/v
template<typename T>
class OT_Queue{//"one time use"
private:
int head,tail;
T *s;
int n;
public:
OT_Queue(){head=tail=0;}
OT_Queue(const OT_Queue &q1){//just a little experiment
throw;
}
OT_Queue(int _n):n(_n){
head=tail=0;
s = new T[n];
}
OT_Queue(T *begin, T *end,int _n):n(_n){
head=0,tail=(end-begin);
s = new T[n];
memcpy(s,begin,sizeof(T)*tail);
}
~OT_Queue(void){
if(s) delete[] s;
}
bool empty(void){return head==tail;}
T front(void){return s[head];}
void pop(void){
if(empty()) throw;
head++;
}
void push(T x){
if(tail>=n) throw;
s[tail++]=x;
}
};
template<typename T>
class Worm_Pack{
public:
OT_Queue<T> worms[3];
Worm_Pack(T *begin,T *end)
:worms{OT_Queue<T>(begin,end,SIZEN),OT_Queue<T>(SIZEM),OT_Queue<T>(SIZEM)}
{}
bool empty(void){
for(int i=0;i<3;i++){
if(!worms[i].empty()) return false;
}
return true;
}
T pop(void){
int k=-1;
for(int t=0;t<3;t++){
if(!worms[t].empty()&&(k==-1||worms[t].front()>worms[k].front())) k=t;
}
if(k==-1) throw -1;
T x=worms[k].front();worms[k].pop();
return x;
}
void push_pair(T y1,T y2){
worms[1].push(y1);
worms[2].push(y2);
}
};
int A[SIZEN];
void work(void){
Worm_Pack<int> W(A+1,A+1+N);
//W.init(A+1,A+1+N);
int delta=0;
for(int i=1;i<=M;i++){
int x=W.pop()+delta;
if(i%T==0) printf("%d ",x);
int y1=(LL)x*U/V,y2=x-y1;
delta+=Q;
W.push_pair(y1-delta,y2-delta);
}
printf("\n");
int tot=0;
while(!W.empty()){
int x=W.pop()+delta;
if((++tot)%T==0) printf("%d ",x);
}
printf("\n");
}
void read(void){
scanf("%d%d",&N,&M);
scanf("%d%d%d%d",&Q,&U,&V,&T);
for(int i=1;i<=N;i++) scanf("%d",&A[i]);
sort(A+1,A+1+N,greater<int>());
}
int main(){
//freopen("input.in","r",stdin);
freopen("earthworm.in","r",stdin);
freopen("earthworm.out","w",stdout);
read();
work();
return 0;
}