|
沙发
楼主 |
发表于 2018-6-12 16:18:53
|
只看该作者
堆会超时,用三个队列即可
- #include <cstdio>
- #include <queue>
- #include <algorithm>
- typedef long long LL;
- const int N = 100010;
- const LL INF = 1ll << 62;
- std::queue<LL> a;
- std::queue<LL> b;
- std::queue<LL> c;
- int m, n, v, u, k, q;
- LL d[N], delta;
- inline void geta(LL &t) {
- t = a.front();
- a.pop();
- return;
- }
- inline void getb(LL &t) {
- t = b.front();
- b.pop();
- return;
- }
- inline void getc(LL &t) {
- t = c.front();
- c.pop();
- return;
- }
- int main() {
- scanf("%d%d%d%d%d%d", &n, &m, &q, &u, &v, &k);
- for(int i = 1; i <= n; i++) {
- scanf("%lld", &d[i]);
- }
- std::sort(d + 1, d + n + 1);
- for(int i = n; i >= 1; i--) {
- a.push(d[i]);
- }
- for(int i = 1; i <= m; i++) {
- LL t;
- if(b.empty() && c.empty()) {
- geta(t);
- }
- else if(a.empty()) {
- if(b.front() >= c.front()) {
- getb(t);
- }
- else {
- getc(t);
- }
- }
- else {
- if(a.front() >= b.front() && a.front() >= c.front()) {
- geta(t);
- }
- else if(b.front() >= c.front()) {
- getb(t);
- }
- else {
- getc(t);
- }
- }
- t += delta;
- if(i % k == 0) {
- printf("%lld ", t);
- }
- LL t1 = t * u / v;
- LL t2 = t - t1;
- delta += q;
- t1 -= delta;
- t2 -= delta;
- b.push(t1);
- c.push(t2);
- }
- puts("");
- a.push(-INF);
- b.push(-INF);
- c.push(-INF);
- for(int i = 1; i <= m + n; i++) {
- LL t;
- if(a.front() >= b.front() && a.front() >= c.front()) {
- geta(t);
- }
- else if(b.front() >= c.front()) {
- getb(t);
- }
- else {
- getc(t);
- }
- if(i % k == 0) {
- printf("%lld ", t + delta);
- }
- }
- return 0;
- }
复制代码 |
|