求助:我的P1428代码为什么超时?
  • 板块灌水区
  • 楼主Liyige321
  • 当前回复3
  • 已保存回复3
  • 发布时间2024/6/2 20:23
  • 上次更新2024/6/2 22:02:01
查看原帖
求助:我的P1428代码为什么超时?
1343781
Liyige321楼主2024/6/2 20:23

听说灌水区大佬多,所以我带着我那全部 re 的代码来求助……大佬们请问我错哪里了?

我的代码:

#include<bits/stdc++.h>
using namespace std;

int n;
int a[101] = {0};

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", a[i]);
	for (int i = 1; i <= n; i++) {
		int Sum = 0;
		for (int j = 0; j <= i; j++)
			if (a[j] < a[i])
				Sum++;
		printf("%d ", Sum);
		Sum = 0;
	}
	return 0;
}

在本地测试时,结果如下:

6
4 3 0 5 1 2

---------------------
Process exited after 17.1 seconds with return value 3221225477

感谢!

2024/6/2 20:23
加载中...