You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
712 B
32 lines
712 B
#include<bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
int main() {
|
|
//红绿灯的设置
|
|
int r, y, g; //red,yellow,green
|
|
cin >> r >> y >> g;
|
|
|
|
int n, sum = 0;
|
|
cin >> n;
|
|
for (int i = 0; i < n; i++) {
|
|
int k, t;
|
|
cin >> k >> t;
|
|
if (k == 0) {
|
|
sum += t; //k=0 表示经过了一段道路,耗时 t 秒
|
|
cout << sum << endl;
|
|
}
|
|
//红灯 红-->绿
|
|
if (k == 1) {
|
|
sum += t;
|
|
cout << sum << endl;
|
|
}
|
|
//黄灯 黄-->红-->绿
|
|
if (k == 2) {
|
|
sum += t + r;
|
|
cout << sum << endl;
|
|
}
|
|
//绿灯
|
|
}
|
|
cout << sum << endl;
|
|
} |