Submission #845404
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef unsigned int ui; typedef long double ld; typedef pair<int, int> ii; typedef pair<ii, ii> iii; ll MOD = 1e9 + 7; const ld E = 1e-7; #define null NULL #define ms(x) memset(x, 0, sizeof(x)) #ifndef LOCAL #define endl "\n" #endif #define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define _read(x) freopen(x, "r", stdin) #define _write(x) freopen(x, "w", stdout) #define files(x) _read(x ".in"); _write(x ".out") #define filesdatsol(x) _read(x ".DAT"); _write(x ".SOL") #define output _write("output.txt") #define input _read("input.txt") #define mod % MOD #define y1 hello_world unsigned char ccc; bool _minus = false; template<typename T> inline T sqr(T t) { return (t * t); } inline void read(ll &n) { n = 0; _minus = false; while (true) { ccc = getchar(); if (ccc == ' ' || ccc == '\n') break; if (ccc == '-') { _minus = true; continue; } n = n * 10 + ccc - '0'; } if (_minus) n *= -1; } inline void read(int &n) { n = 0; _minus = false; while (true) { ccc = getchar(); if (ccc == ' ' || ccc == '\n') break; if (ccc == '-') { _minus = true; continue; } n = n * 10 + ccc - '0'; } if (_minus) n *= -1; } char wwww[19]; int kkkk; inline void write(ll y) { long long x = y; kkkk = 0; if (!x) ++kkkk, wwww[kkkk] = '0'; else while (x) { ++kkkk; wwww[kkkk] = char(x % 10 + '0'); x /= 10; } for (int i = kkkk; i >= 1; --i) putchar(wwww[i]); putchar('\n'); } #ifdef LOCAL //#define DEBUG #endif int main() { srand(time(NULL)); cout.precision(10); cout << fixed; sync; #ifdef LOCAL input; #else #endif int n; cin >> n; vector<ii> v; for(int i = 0; i < n; i++){ int a; cin >> a; v.push_back(make_pair(a, i)); } sort(v.begin(), v.end()); int ans = 0; for(int i = 0; i < n; i++){ if(i % 2 != v[i].second % 2) ans++; } assert(ans % 2 == 0); ans /= 2; cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | C - BBuBBBlesort! |
User | arsijo |
Language | C++14 (GCC 5.4.1) |
Score | 600 |
Code Size | 2108 Byte |
Status | AC |
Exec Time | 38 ms |
Memory | 1400 KB |
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 | 38 ms | 1400 KB |
02.txt | AC | 37 ms | 1400 KB |
03.txt | AC | 38 ms | 1400 KB |
04.txt | AC | 38 ms | 1400 KB |
05.txt | AC | 33 ms | 1400 KB |
06.txt | AC | 33 ms | 1400 KB |
07.txt | AC | 33 ms | 1400 KB |
08.txt | AC | 25 ms | 1400 KB |
09.txt | AC | 28 ms | 1400 KB |
10.txt | AC | 23 ms | 1400 KB |
11.txt | AC | 24 ms | 1400 KB |
12.txt | AC | 25 ms | 1400 KB |
13.txt | AC | 24 ms | 1400 KB |
14.txt | AC | 34 ms | 1400 KB |
15.txt | AC | 34 ms | 1400 KB |
16.txt | AC | 34 ms | 1400 KB |
17.txt | AC | 34 ms | 1400 KB |
18.txt | AC | 4 ms | 256 KB |
19.txt | AC | 4 ms | 256 KB |
20.txt | AC | 4 ms | 256 KB |
21.txt | AC | 4 ms | 256 KB |
22.txt | AC | 4 ms | 256 KB |
s1.txt | AC | 4 ms | 256 KB |
s2.txt | AC | 4 ms | 256 KB |