比赛 2025.12.13 评测结果 AAAAAAAAAAAAAAAAAAAA
题目名称 排列变换 最终得分 100
用户昵称 李奇文 运行时间 0.767 s
代码语言 C++ 内存使用 5.57 MiB
提交时间 2025-12-13 12:21:51
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
const int N=2e6+5;
int n,t[N],x,ans;
int main(){
	freopen("permutrans.in","r",stdin);
	freopen("permutrans.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i(1);i<=n;++i){
		cin>>x;
		if(i<=x){
			if(i<=x){
				t[0]++;
				t[x-i+1]--;
			}
			if(n-i+1<=n-1){
				t[n-i+1]++;
				t[n+x-i+1]--;
			}
		}else{
			if(n-i+1<=n+x-i){
				t[n-i+1]++;
				t[n+x-i+1]--;
			}
		}
	}
	for(int i(1);i<=n;++i) t[i]+=t[i-1];
	for(int i(1);i<n;++i){
		if(t[i]>t[ans]) ans=i;
	}
	cout<<t[ans]<<" "<<ans<<"\n";
	return 0;
}