Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|---|
40621 | 张浩然 | 公鸡打鸣 | C++ | Accepted | 100 | 40 MS | 252 KB | 416 | 2022-05-29 18:56:33 |
#include<bits/stdc++.h> using namespace std; int G1,G2,s,k,a,x,b,y; int main(){ cin>>G1>>G2>>k; if(G1==G2){ cout<<0; return 0; } for(int i=1;i<=k;i++){ cin>>a>>x>>b>>y; if(a==1) G1+=x; else if(G1-x>=0) G1-=x; else G1=0; // cout<<i<<endl<<G1<<endl; if(b==1) G2+=y; else if(G2-y>=0) G2-=y; else G2=0; if(G1==G2){ cout<<i; return 0; } } cout<<-1; return 0; }