mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 18:52:02 +00:00
P1116 车厢重组
R38788162
This commit is contained in:
parent
46fc18cd1d
commit
4df57d2fda
25
problem/P1116/P1116.cpp
Normal file
25
problem/P1116/P1116.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
// R38788162
|
||||
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int n, a[10005], ans = 0;
|
||||
cin >> n;
|
||||
for (int i = 0; i < n; i++) {
|
||||
cin >> a[i];
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 1; j < n; j++) {
|
||||
if (a[j] < a[j - 1]) {
|
||||
a[j] ^= a[j - 1];
|
||||
a[j - 1] ^= a[j];
|
||||
a[j] ^= a[j - 1];
|
||||
ans++;
|
||||
}
|
||||
}
|
||||
}
|
||||
cout << ans << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user