题意:有n个物品,每个物品吃掉的时间是a[i],一个人从左边开始吃,一个人从右边开始吃,如果两个人同时吃到了一个东西,算左边的。最后问你左边吃了多少个,右边吃了多少个
思路:直接暴力扫吧...
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+7;
long long a[maxn];
int main()
{
int n;scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%lld",&a[i]);
long long t1=0,t2=0;
int num1=0,num2=0;
int l=1,r=n;
while(l<=r)
{
if(t1<=t2)t1+=a[l++],num1++;
else t2+=a[r--],num2++;
}
cout<<num1<<" "<<num2<<endl;
}