AcWing 3268. 小明放学
原题链接
简单
作者:
Value
,
2021-04-10 10:09:51
,
所有人可见
,
阅读 509
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
int main(){
int r, y, g; cin >> r >> y >> g;
int T; cin >> T;
ll res = 0;
while(T -- ){
ll op, t; scanf("%lld%lld", &op, &t);
if(op == 0) res += t;
else{
if(op == 1) t = r - t;
else if(op == 2) t = r + g + y - t;
else t = r + g - t;
t += res;
t %= r + g + y;
if(t < r) res += r - t;
else if(t >= r + g) res += r + g + y - t + r;
}
}
cout << res << endl;
return 0;
}