提交时间:2022-07-20 11:54:52

运行 ID: 52784

#include<bits/stdc++.h> #define int long long using namespace std; inline int read() { int x=0; char c=getchar(); for(; c<'0' || c>'9'; c=getchar()); for(; c<='9' && c>='0'; c=getchar()) x=(x<<3)+(x<<1)+c-'0'; return x; } int ans; int n; int a[100000]; int f; int l; main() { n = read(); f = n; for(int i=1; i<=n; i++) a[i] = read(); for(int f=n; f>=1; f--) { int Max = -10000; for(int i=f-1; i>=1; i--) { if(a[i] > a[f]) { cout << a[f] << " " << a[i] << endl; Max = a[i]; l = i; } } ans += f-l; } cout << ans << endl; return 0; }