比赛 |
CSP2023-J模拟赛 |
评测结果 |
AAAAAAAAAATTTTTTTTTT |
题目名称 |
排列变换 |
最终得分 |
50 |
用户昵称 |
leaf |
运行时间 |
10.402 s |
代码语言 |
C++ |
内存使用 |
13.36 MiB |
提交时间 |
2023-10-18 18:57:31 |
显示代码纯文本
- #include<bits/stdc++.h>
- using namespace std;
- int a[1000010],b[1000010];
- int main(){
- freopen("permutrans.in","r",stdin);
- freopen("permutrans.out","w",stdout);
- queue <int> q;
- int x,sum,num,maxn,get,n;
- cin>>n;
- for(int i = 0;i < n;i++){
- cin>>a[i];
- }
- for(int i = n-1;i >= 0;i--){
- q.push(a[i]);
- }
- num = 0;
- for(int i = 0;i < n;i++){
- sum = 0;
- for(int j = 0;j < n;j++){
- x = q.front();
- q.pop();
- q.push(x);
- if(x >= n-j){
- sum++;
- }
- }
- b[i] = num++;
- a[i] = sum;
- x = q.front();
- q.pop();
- q.push(x);
- }
- maxn = -1;
- for(int i = 0;i < n;i++){
- if(a[i] > maxn){
- maxn = a[i];
- get = i;
- }
- }
- cout<<maxn<<" "<<b[get];
- return 0;
- }
-