大佬求调,死循环
查看原帖
大佬求调,死循环
1428467
happy_today楼主2025/1/18 19:24
#include<bits/stdc++.h>
using namespace std;
int a[1000005];
int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++)
	{
		cin >> a[i];
	}
	int x = 1;
	for(int i = x; i < n; i ++)
	{
		i = x;
		if(a[i] + a[i + 1] > x)
		{
			a[i + 1] = -1;
			for(int j = i + 2; j <= n; j ++)
			{
				if(a[i] + a[j] > x)
				{
					a[j] = -1;
				}
				else
				{
					x = j;
					break;
				}
			}
		}
	}
	return 0;
}
2025/1/18 19:24
加载中...