比赛 |
CSP2023-J模拟赛 |
评测结果 |
AAAAAAAAAATTTTTTTTTT |
题目名称 |
排列变换 |
最终得分 |
50 |
用户昵称 |
xuuu |
运行时间 |
10.635 s |
代码语言 |
C++ |
内存使用 |
6.20 MiB |
提交时间 |
2023-10-18 20:07:52 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
inline int read(){
int x = 0,f = 1;
char ch = getchar();
while(ch < '0'||ch > '9')
{
if(ch == '-')
f = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9')
x = x * 10 + ch - '0',ch = getchar();
return x*f;
}
int n,pos,tot;
deque<int> a;
int main(){
freopen("permutrans.in","r",stdin);
freopen("permutrans.out","w",stdout);
n = read();
for(int i = 1;i <= n;i ++){
int x;
x = read();
a.push_back(x);
}
int maxg = -1;
for(int i = 1;i <= n - 1;i ++){
int tmp = a.back();
a.pop_back();
a.push_front(tmp);
tot = 0;
for(int j = 1;j <= n;j ++){
if(a[j] >= j) tot ++;
}
if(tot > maxg){
maxg = tot;
pos = i;
}
continue;
}
cout<<maxg<<" "<<pos-1;
return 0;
}