#include <bits/stdc++.h>
using namespace std;
using PII = pair<int,int >;
using ll = long long;
using VI = vector<int>;
using namespace std;
//a b
//c d
ll n,m,q,u,v,t;
priority_queue<long long> pq;
VI a,r;
int main(){
//priority_queue<int> pq;
cin>>n>>m>>q>>u>>v>>t;
for(int i=1;i<=n;i++){
int x;
cin>>x;;
pq.push(x);
}
//每个没被切的蚯蚓会增长q , 不妨将新加入的蚯蚓再砍了q
//维护相对大小,同时维护这个数组会被加几个q
ll add = 0;
for(int i=1;i<=m;i++){
auto x = pq.top() + add;
pq.pop();
if(i % t == 0){
cout<<x<<" ";
}
int px = x * u / v;
int ps = x - px;
px -= add, ps -= add;
px -= q, ps -= q;
pq.push(px) , pq.push(ps);
add += q;
}
ll time = 1;
cout<<"\n";
while (pq.size()){
auto x = pq.top() + add;
pq.pop();
if(time % t == 0){
cout<<x<<" ";
}
time ++;
}
}
非正解,但是里面的思想还是很重要的,就是每个数都加q,不妨就把新的蚯蚓减去q, 用add来维护加了多少次
——————————————————————————————————————————
#include <bits/stdc++.h>
using namespace std;
using PII = pair<int,int >;
using ll = long long;
using VI = vector<int>;
using namespace std;
//a b
//c d
ll n,m,q,u,v,t;
priority_queue<long long> pq;
VI tmp;
queue<ll> a,b,c;
bool cmp(ll x ,ll y){
return x > y;
}
ll getMax(){
ll res = -1e18;
if(a.size()) res = max(res,a.front());
if(c.size()) res = max(res,b.front());
if(b.size()) res = max(res,c.front());
if(a.size() && res == a.front()) a.pop();
else if( b.size() && res == b.front()) b.pop();
else if( c.size() && res == c.front() ) c.pop();
return res;
}
int main(){
//priority_queue<int> pq;
cin>>n>>m>>q>>u>>v>>t;
for(int i=1;i<=n;i++){
int x;
cin>>x;
tmp.push_back(x);
}
sort(tmp.begin(),tmp.end(),cmp);
for(auto x : tmp) a.push(x);
ll add = 0;
for(int i=1;i<=m;i++){
auto x = getMax() + add;
if(i % t == 0){
cout<<x<<" ";
}
ll px = x * u / v;
ll ps = x - px;
if(ps < ps) swap(ps,px);
px -= add , ps -= add;
px -= q , ps -= q;
b.push(px) , c.push(ps);
add += q;
}
cout<<"\n";
//每个没被切的蚯蚓会增长q , 不妨将新加入的蚯蚓再砍了q
//维护相对大小,同时维护这个数组会被加几个q
while(a.size()) pq.push(a.front()),a.pop();
while(b.size()) pq.push(b.front()),b.pop();
while(c.size()) pq.push(c.front()),c.pop();
int time = 1;
while(pq.size()){
if(time % t == 0){
cout<<pq.top() + add<<" ";
}
pq.pop();
time ++;
}
}
正解需要能观察出一定的性质,
如果蚯蚓 a 比 b 先被切,那么他的子段就一定比b先切