80分 4点WA 测试数据已下载,没有问题.
查看原帖
80分 4点WA 测试数据已下载,没有问题.
1065928
XiaoYuyu楼主2023/10/10 11:35

以下是程序,求助

#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int n; int a[20000],count=1,temp,max_count=1;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		if (a[i] - a[i - 1] == 1) count++;
		else
		{
			temp = count;
			if (temp > max_count) max_count = temp;
			count = 1;
		}
		
	}
	if (count > max_count) max_count = count;
	cout << max_count << endl;
}
2023/10/10 11:35
加载中...