mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 19:08:47 +00:00
parent
d8e347f8ab
commit
b5d6d5a0fc
38
S2OJ/1550/1550.cpp
Normal file
38
S2OJ/1550/1550.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 1e5 + 5;
|
||||
|
||||
int n, a[N], c[N], p, ans;
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n;
|
||||
|
||||
bool flag = n >= 3;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> a[i];
|
||||
|
||||
if (a[i] == n) p = i;
|
||||
}
|
||||
|
||||
flag &= a[1] == n - 1 && a[n] == n;
|
||||
|
||||
for (int i = 1; i < p; i++) {
|
||||
if (a[i] > a[i + 1]) {
|
||||
ans++;
|
||||
std::swap(a[i], a[i + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
cout << static_cast<long long>(n) * (n - 1) + ans - flag << endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
S2OJ/1550/data/bubble1.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble1.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble10.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble10.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble2.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble2.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble3.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble3.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble4.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble4.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble5.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble5.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble6.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble6.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble7.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble7.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble8.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble8.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble9.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble9.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user