MENG_QI @ 2024-07-19 22:05:32
#include<bits/stdc++.h>
#define int long long
#define N 500005
using namespace std;
int n , ans = 0 , len;
int a[N];
int dfs(int st,int sum){
if(st==len)return sum;
if(a[st+1]<a[st])dfs(st+1,sum+1);
}
signed main(){
scanf("%d",&n);
for(int i = 1;i <= n;i++){
scanf("%d",&a[i]);
}
len = unique(a+1,a+1+n) - (a+1);
for(int i = 1;i <= n;i++){
a[i] = lower_bound(a+1,a+1+len,a[i])-a;
}
for(int i = 1;i < n;i++){
ans += dfs(a[i],0);
}
printf("%d",ans);
return 0;
}
by Umbrelliar @ 2024-07-20 02:35:48
没有离散化
by noruto @ 2024-07-22 09:57:11
@MENG_QI 不是凤雏,你还活着啊 我还以为你不学了,快点回关我
by noruto @ 2024-07-22 09:57:51
@noruto 我是卧龙
by noruto @ 2024-07-22 10:02:09
@MENG_QI 要离散化