1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
| #include <queue> #include <cctype> #include <cstdio> #include <algorithm> using namespace std; typedef long long LL; const int Mn(100005),Mm(7000005);
template<typename T> void qrd(T& x) { x = 0; char c = getchar(); while(!isdigit(c)) { c = getchar(); } while(isdigit(c)) { x = x*10 + (c-'0'); c = getchar(); } }
int n,m;
class Queue { private: int* arr; const int size; int head, tail; public: const static int NIL = 0x80000000; explicit Queue(int size): size(size), head(0), tail(0) { arr = new int[size]; } void push(int x) { arr[tail] = x; tail = (tail + 1) % size; } int front() { if(head == tail) { return NIL; } else { return arr[head]; } } void pop() { head = (head + 1) % size; } }org(Mn),spl1(Mm),spl2(Mm);
int a[Mn];
int main() { int q,u,v,t; qrd(n), qrd(m), qrd(q), qrd(u), qrd(v), qrd(t); for(int i(1);i<=n;++i) { qrd(a[i]); } sort(a+1,a+n+1,[](int a,int b) -> bool { return a>b; }); for(int i(1);i<=n;++i) { org.push(a[i]); } int add(0); int mul(1); for(int i(1);i<=m;++i) { int nlen = max(max(org.front(),spl1.front()),spl2.front()) + add; if(i==mul*t) { printf("%d ",nlen); ++mul; } if(org.front()==nlen-add) { org.pop(); } else if(spl1.front()==nlen-add) { spl1.pop(); } else { spl2.pop(); } int llen = 1ll*nlen*u/v, rlen = nlen-llen; add += q; spl1.push(llen-add), spl2.push(rlen-add); } printf("\n"); while(true) { for(int i(1);i<t;++i) { int nlen = max(max(org.front(),spl1.front()),spl2.front()); if(nlen == Queue::NIL) { break; } if(org.front()==nlen) { org.pop(); } else if(spl1.front()==nlen) { spl1.pop(); } else { spl2.pop(); } } int nlen = max(max(org.front(),spl1.front()),spl2.front()); if(nlen == Queue::NIL) { break; } printf("%d ",nlen+add); if(org.front()==nlen) { org.pop(); } else if(spl1.front()==nlen) { spl1.pop(); } else { spl2.pop(); } } return 0; }
|