Submission #845921
Source Code Expand
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
using namespace std;
template <class T, class P>
ostream &operator << (ostream &out, pair<T, P> &a){
out << a.F << " " << a.S;
return out;
}
template <class T>
ostream &operator << (ostream &out, vector <T> &a){
for(auto &x : a)out << x << ' ';
return out;
}
template <class T>
ostream &operator << (ostream &out, set <T> &a){
for(auto &x : a) out << x << ' ';
return out;
}
template <class T, class P>
ostream &operator << (ostream &out, map <T, P> &a){
for(auto &x : a) out << x.F << " " << x.S << endl;
return out;
}
const int N = 1e5 + 10;
const ll INF = 1e9 + 7;
int n;
string s;
ll t[N], d[N];
ll ans;
map <ll, ll> mp;
void solution(){
int cnt = 0;
cin >> n;
for(int i = 1; i <= n; i++){
cin >> t[i];
d[i] = t[i];
}
sort(d + 1, d + 1 + n);
for(int i = 1; i <= n; i++){
mp[d[i]] = i;
}
for(int i = 1; i <= n; i++){
if(abs(i - mp[t[i]]) % 2 == 1)cnt++;
}
cout << cnt / 2;
}
int main(){
int n = 1;
//cin >> n;
while(n){
n--;
solution();
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - BBuBBBlesort! |
| User | klinchuh |
| Language | C++14 (GCC 5.4.1) |
| Score | 600 |
| Code Size | 1232 Byte |
| Status | AC |
| Exec Time | 233 ms |
| Memory | 8064 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 600 / 600 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | s1.txt, s2.txt |
| All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, s1.txt, s2.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01.txt | AC | 231 ms | 8064 KiB |
| 02.txt | AC | 233 ms | 8064 KiB |
| 03.txt | AC | 230 ms | 8064 KiB |
| 04.txt | AC | 230 ms | 8064 KiB |
| 05.txt | AC | 196 ms | 8064 KiB |
| 06.txt | AC | 199 ms | 8064 KiB |
| 07.txt | AC | 195 ms | 8064 KiB |
| 08.txt | AC | 156 ms | 8064 KiB |
| 09.txt | AC | 153 ms | 8064 KiB |
| 10.txt | AC | 152 ms | 8064 KiB |
| 11.txt | AC | 153 ms | 8064 KiB |
| 12.txt | AC | 153 ms | 8064 KiB |
| 13.txt | AC | 154 ms | 8064 KiB |
| 14.txt | AC | 193 ms | 8064 KiB |
| 15.txt | AC | 193 ms | 8064 KiB |
| 16.txt | AC | 191 ms | 8064 KiB |
| 17.txt | AC | 192 ms | 8064 KiB |
| 18.txt | AC | 4 ms | 256 KiB |
| 19.txt | AC | 4 ms | 256 KiB |
| 20.txt | AC | 4 ms | 256 KiB |
| 21.txt | AC | 4 ms | 256 KiB |
| 22.txt | AC | 4 ms | 256 KiB |
| s1.txt | AC | 4 ms | 256 KiB |
| s2.txt | AC | 4 ms | 256 KiB |