原来真的是按题意模拟啊,还以为有高能的算法可以直接算每个$t$的值。

考虑到先切的蚯蚓一定比后切的蚯蚓长,于是可以弄三个队列分别存放原来的序列和两个切开后的序列,每次取出三个队头的最大值进行扩展。

考虑到每秒钟除了取出来的队头其他的长度都会增加$q$,那么我们可以写一个全局变量$tag$标记现在进行了几轮,然后每一次进队的时候反向减去这一个$tag$就好了。

时间复杂度$O(nlogn)$。

$stl$的$queue$开了$O2$之后就很快了

Code:

#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;
typedef double db; const int N = 7e6 + ;
const int inf = << ; int n, m, q, t, a[N * ];
db p;
queue <int> Q[]; inline void read(int &X) {
X = ;
char ch = ;
int op = ;
for(; ch > ''|| ch < ''; ch = getchar())
if(ch == '-') op = -;
for(; ch >= '' && ch <= ''; ch = getchar())
X = (X << ) + (X << ) + ch - ;
X *= op;
} bool cmp(const int x, const int y) {
return x > y;
} inline int bet(int x, int y, int rx, int ry) {
return rx > ry ? x : y;
} inline int getQ(int now) {
if(Q[now].empty()) return -inf;
else return Q[now].front();
} inline int getMax() {
int res[];
for(int i = ; i < ; i++) res[i] = getQ(i);
return bet(bet(, , res[], res[]), , res[bet(, , res[], res[])], res[]);
} int main() {
int u, v;
read(n), read(m), read(q), read(u), read(v), read(t);
p = (db)u / v; for(int i = ; i <= n; i++) read(a[i]); sort(a + , a + + n, cmp);
for(int i = ; i <= n; i++) Q[].push(a[i]); int tag = ;
for(int i = ; i <= m; i++) {
int now = getMax();
int z = Q[now].front() + tag;
Q[now].pop();
if(i % t == ) printf("%d ", z);
int x = (int)z * p, y = z - x;
tag += q;
x -= tag, y -= tag;
Q[].push(x), Q[].push(y);
}
printf("\n"); int len = ;
for(int i = ; i < ; i++)
for(;!Q[i].empty(); Q[i].pop())
a[++len] = Q[i].front();
sort(a + , a + + len, cmp); /* for(int i = 1; i <= len; i++)
printf("%d ", a[i]);
printf("\n"); */ int cnt = (n + m) / t;
for(int i = ; i <= cnt; i++)
printf("%d ", a[i * t] + tag);
printf("\n"); return ;
}

最新文章

  1. iOS 保存、读取与应用状态
  2. 在Windows系统搭建.NET Core环境并创建运行ASP.NET网站
  3. js 过滤敏感词
  4. Javascript对象赋值操作
  5. ABAP RFC远程调用
  6. Linux使用locate命令定位文件
  7. 手机调用系统的拍照和裁剪功能,假设界面有输入框EditText,在一些手机会出现点击EditText会弹出输入法,却不能输入的情况。
  8. 基于mongoDB的capped collection的性能优化
  9. Shell: how to list all db links in oracle DB to generate a flat file (生成dblink列表文件)
  10. Python 函数的参数知识汇总
  11. 【复习】VueJS之内部指令
  12. bolt_storage.go
  13. 虚拟机14安装kail Linux
  14. 浅谈final关键字的用法
  15. 无法获得锁 /var/lib/dpkg/lock
  16. android app与服务器交互
  17. bzoj3224 splay板子
  18. org.jeecgframework.core.common.exception.MyExceptionHandler]java.lang.NullPointerException
  19. .NET Core2.0 环境下MVC模式的支付宝扫码支付接口-沙箱环境开发测试
  20. html 列表相关信息

热门文章

  1. Linux-Crontab服务
  2. 剑指offer--14.求1+2+3+...+n
  3. 2018-2019-2 20165210《网络对抗技术》Exp6 信息搜集与漏洞扫描
  4. golang实现模拟键盘按键
  5. zookeeper安装搭建
  6. HDFS超租约异常总结(org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException)
  7. [转]express 路由控制--next
  8. 第八篇 web开发学习资源
  9. div+css制作带箭头提示框效果图(原创文章)
  10. DCloud-MUI:杂项