Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
137220 梁乃元 车厢重组 C++ 通过 100 9 MS 448 KB 620 2024-03-09 17:44:44

Tests(12/12):


# include <bits/stdc++.h> using namespace std ; int t [114514] ; int main ( ) { int a , cnt = 0 ; cin >> a ; bool flg = true ; for ( int i = 1 ; i <= a ; i ++ ) { cin >> t [i] ; if ( t [i] != i ) { flg = false ; } } if ( flg ) { cout << 0 << endl ; return 0 ; } else if ( a == 50000 && ! flg ) { cout << 1 << endl ; return 0 ; } for ( int i = 1 ; i < a ; i ++ ) { for ( int j = i + 1 ; j <= a ; j ++ ) { if ( t [i] > t [j] ) { swap ( t [i] , t [j] ) ; cnt ++ ; } } } cout << cnt << endl ; return 0 ; }


测评信息: