大佬求助,玄关(80分)

P1568 赛跑

数组再开大一点。@[wch666](https://www.luogu.com.cn/user/778382)
by _txb_ @ 2024-01-10 20:11:06


@[wch666](/user/778382) ``` #include<bits/stdc++.h> using namespace std; int n,m,i=1,j=1,as,bs,ans; bool flag; struct node { int s,t; } a[1005],b[1005]; int main() { cin>>n>>m; for(int i=1; i<=n; i++) cin>>a[i].s>>a[i].t; for(int i=1; i<=m; i++) cin>>b[i].s>>b[i].t; if(a[1].s>b[1].s) flag=true; while(i<=n&&j<=m) { if(a[i].t==0) i++; if(b[j].t==0) j++; as+=a[i].s; a[i].t--; bs+=b[j].s; b[j].t--; if(as>bs&&flag==false) { ans++; flag=true; } else if(as<bs&&flag==true) { ans++; flag=false; } } cout<<ans; return 0; } ```
by xwx123456 @ 2024-01-13 10:09:03


|