-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathp4.cpp
More file actions
35 lines (32 loc) · 681 Bytes
/
Copy pathp4.cpp
File metadata and controls
35 lines (32 loc) · 681 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include<iostream>
using namespace std;
using ll=long long;
void solve(){
int g,y,r,n; cin>>r>>y>>g>>n;
int c=g+y+r;
ll time=0;
// green -> yellow -> red
for(int i=1;i<=n;i++){
int k,t; cin>>k>>t;
if(k==0) time+=t;
else{
int x;
if(k==1) x=g+y+r;
else if(k==2) x=g+y;
else if(k==3) x=g;
int lt=(x-t+time)%c;
if(lt<=g);
else time+=c-lt;
}
//cerr<<"time="<<time<<' ';
}
cout<<time<<'\n';
}
int main(){
ios::sync_with_stdio(0),
cin.tie(0),cout.tie(0);
int t=1;
//cin>>t;
while(t--) solve();
return 0;
}