#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int r, y, g;
int n;
cin >> r >> y >> g;
cin >> n;
long long sum_time = 0;
for(int i = 0; i < n; i++) {
int k, t;
cin >> k >> t;
if(k == 0) sum_time += t;
else if(k == 1) {
int temp = (sum_time % (r + y + g)) - t;
if(temp < 0) sum_time += abs(temp);
else if(temp > g) sum_time = y + r + g - temp + sum_time;
}
else if(k == 2) {
int temp = (sum_time % (r + y + g)) - t - r;
if(temp < 0) sum_time += abs(temp);
else if(temp > g) sum_time = y + r + g - temp + sum_time;
}
else if(k == 3) {
int temp = (sum_time % (r + y + g)) - t;
if(temp < y + r && temp > 0) sum_time = sum_time + y + r - temp;
}
}
cout << sum_time;
return 0;
}
【题解】CCF CSP 201812-2 —— 小明放学
最新推荐文章于 2024-11-16 10:02:08 发布