CCF CSP-201812-2 小明放学(C++)
作者:互联网
#include <cstdio>
int r, y, g;
int wait(long long t){
int sumtime = r + y+ g;
t = t%=sumtime;
if(t < r){
return r - t;
}else if(t < r+g){
return 0;
}else{
return sumtime - t + r;
}
}
int main(){
scanf("%d %d %d", &r, &y, &g);
int n;
scanf("%d", &n);
long long sum = 0;
for(int i=0; i<n; i++){
int k, t;
scanf("%d %d", &k, &t);
if(k == 0){
sum += t;
}else if(k == 1){
long long temp = sum + r - t;
int time = wait(temp);
sum += time;
}else if(k == 2){
long long temp = sum + r + g + y - t;
int time = wait(temp);
sum += time;
}else if(k == 3){
long long temp = sum + r + g - t;
int time = wait(temp);
sum += time;
}
}
printf("%lld", sum);
return 0;
}
标签:temp,int,sum,long,else,201812,C++,time,CCF 来源: https://blog.csdn.net/weixin_45964844/article/details/110744576