90分求调
查看原帖
90分求调
1081586
Circle_Table楼主2025/7/1 10:33

为什么2#TLE啊

#include <bits/stdc++.h>
#define ll long long
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int n,h[80005];
ll c,ans;

int main(){
	ios;cin>>n;
	for(int i=1;i<=n;i++){
		cin>>h[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(h[i]>h[j])ans++;
			else break;
		}
	}
	cout<<ans;
	return 0;
}

QwQ

2025/7/1 10:33
加载中...