WA求救
查看原帖
WA求救
1558578
liuqinghao1楼主2024/12/6 19:18

求求了

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int m,n,t=0,i1=0;
    double temp=0;
    cin>>m;
    for(int i=0;i<m;i++)
    {
        temp=0;
        cin>>n;
        int a[n];
        for(int j=0;j<n;j++)
        {
            cin>>a[j];
            temp+=a[j];
        }
        t=temp/2;
        for(int j=0;j<n;j++)
        {
            if(t>0) t-=a[j];
            if(t=0){i1=j;break;}
            if(t<0) break;
        }
        if(i1)cout<<i1<<endl<<t<<endl<<temp<<"Yes"<<endl;
        else cout<<i1<<endl<<t<<endl<<temp<<"No"<<endl;
	}
	return 0;
}

大佬看一眼

2024/12/6 19:18
加载中...