Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
127262 魈凯KBS 车厢重组 C++ 通过 100 9 MS 448 KB 543 2024-01-25 08:30:32

Tests(12/12):


#include <bits/stdc++.h> using namespace std; const int N=5e4+10; int n,x,a[N]; long long ans=0; string s; int main() { cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; } for(int i=n;i>1;i--) { bool ok=1;//判断是否在某一时段全部排好 for(int j=1;j<i;j++) { if(a[j]>a[j+1]) { ans++; swap(a[j],a[j+1]);//模拟 ok=0; } } if(ok)//排好了,后面的就不用排了 { break; } } // for(int i=1;i<=n;i++) // { // cout<<a[i]; // } cout<<ans; return 0; }


测评信息: