import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
long r =scan.nextInt();
long y=scan.nextInt();
long g=scan.nextInt();
long total=r+y+g;
int n = scan.nextInt();
long res=0;
for (int i = 0; i < n; i++) {
long k = scan.nextInt();
long t = scan.nextInt();
if(k==0){
res+=t;
}
if(k==1){
if(t>=res){
res=t;
}else {
long m=(res-t)%total;
if(m>g){
res+=total-m;
}
}
}
if(k==2){
if(t+r>=res){
res=t+r;
}
else {
long m=(res-t-r)%total;
if(m>g){
res+=total-m;
}
}
}
if(k==3){
if(t<res){
long m=(res-t)%total;
if(m<r+y){
res+=r+y-m;
}
}
}
}
System.out.println(res);
}
}
07-24
291
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交