50pts,求调
  • 板块P9815 wbyblD
  • 楼主Wch_1910231
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/11/3 22:57
  • 上次更新2023/11/4 09:43:54
查看原帖
50pts,求调
361676
Wch_1910231楼主2023/11/3 22:57
#include<bits/stdc++.h>
using namespace std;
int T,a[100010],b[100010];
inline int readd()
{
	char c;
	bool flag=false;
	while((c=getchar())>'9'||c<'0')if(c=='-')flag=true;
	int res=c-'0';
	while((c=getchar())>='0'&&c<='9')res=(res<<3)+(res<<1)+c-'0';
	return flag ? -res : res;
}
int main()
{
	T=readd();
    while(T)
	{
		T-=1;
        int n=readd();
        for(int i=1;i<=n;++i)a[i]=readd(),b[i]=readd(); 
        int x=0,y=1;
        while(true)
		{
            if((x==0&&y==-1)||(x==n+1&&y==1))break;
            if(y==1)
			{
                x+=1;
                if(a[x-1]>0)y=-1;
                a[x-1]-=1;
            }
			else
			{
                x-=1;
                if(b[x-1]>0)y=1;
                b[x-1]-=1;
            }
        }
        cout<<x<<endl;
    }
    return 0;
}
2023/11/3 22:57
加载中...