跳到正文

题解

题解:P1698 [USACO18JAN] Out of Place B

llyd约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟
题目
P1698

版本

  1. v2当前
  2. v1

AC代码:

#include<bits/stdc++.h>

using namespace std;

int w[100001],re[100001];

int main(){

int h;

cin>>h;

for(int j=1;j<=h;j++){

cin>>w[j];

re[j]=w[j];

}

sort(re+1,re+h+1);

int sum=-1;

for (int j=1;j<=h;j++){

if (w[j]!=re[j]){

sum++;

}

}

cout<<sum;

return 0;

}

原文