洛谷P2827 蚯蚓
传送门 pts85/90(90应该是个意外,第一次交是90之后都是85了): 优先队列模拟题意 #include<iostream> #include<cstdio> #include<queue> using namespace std; int n,m,q,u,v,t,tim; double p; priority_queue<int>qq; int main() { scanf("%d%d%d%d%d%d",&n,&m,&q,&u,&v,&t); p=1.0*u/(1.0*v); for(int i=1,x;i<=n;i++){ scanf("%d",&x); qq.push(x); } while(m--){ tim++; int x=qq.top(); qq.pop(); if(tim%t==0)printf("%d ",x+(tim-1)*q); int y=(int)(p*(double)(x+(tim-1)*q)); x=(x+(tim-1)*q)-y; qq.push(x-tim*q),qq.push(y-tim*q); } printf("\n"); int now=0; while(qq.size()){ now++; if(now%t==0){ printf("%d ",qq.top()+tim*q); } qq.pop(); } return 0; }