https://www.luogu.com.cn/problem/P3926
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
int main(){
int a,c,p,q,r,x;
cin>>a>>c>>p>>q>>r>>x;
if(a<c){
int t1=c-a;
int r1=t1*p;
if(x>=r1){
a+=t1;
x-=r1;
}else{
a+=(x/p);
cout<<a;
return 0;
}
}
if(a==c){
x-=q;
}
if(x<=0){
cout<<a;
return 0;
}
if(a>c){
int t2=c-a;
int r2=t2*r;
if(x>=r2){
a+=t2;
x-=r2;
}else{
a+=(x/r);
cout<<a;
}
}
return 0;
}