Submission #4262458
Source Code Expand
#include<bits/stdc++.h> using namespace std; long long read() { long long x=0,f=1; char c=getchar(); while(c<'0'||c>'9') { if(c=='-') { f=-1; } c=getchar(); } while(c<='9'&&c>='0') { x=(x<<1)+(x<<3)+(c^48); c=getchar(); } return x*f; } int n; struct node { long long num; long long a; long long tot; }s[100503]; bool cmp(node a,node b) { return a.num<b.num; } long long ji,ou; int main() { n=read(); for(int i=1;i<=n;++i) s[i].num=read(),s[i].a=i; stable_sort(s+1,s+1+n,cmp); for(int i=1;i<=n;++i) { if(s[i].a%2==0) { if(i%2==0) continue; else ou++; } else { if(i%2!=0) continue; else ji++; } } long long h=min(ou,ji); cout<<h+abs(ou-ji); }
Submission Info
Submission Time | |
---|---|
Task | C - BBuBBBlesort! |
User | vjudge4 |
Language | C++14 (GCC 5.4.1) |
Score | 600 |
Code Size | 936 Byte |
Status | AC |
Exec Time | 25 ms |
Memory | 4864 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 | 25 ms | 4864 KB |
02.txt | AC | 25 ms | 3712 KB |
03.txt | AC | 25 ms | 3712 KB |
04.txt | AC | 25 ms | 3712 KB |
05.txt | AC | 22 ms | 3712 KB |
06.txt | AC | 22 ms | 3712 KB |
07.txt | AC | 22 ms | 4864 KB |
08.txt | AC | 14 ms | 4864 KB |
09.txt | AC | 14 ms | 3712 KB |
10.txt | AC | 14 ms | 3712 KB |
11.txt | AC | 14 ms | 3712 KB |
12.txt | AC | 14 ms | 3712 KB |
13.txt | AC | 14 ms | 3712 KB |
14.txt | AC | 22 ms | 3712 KB |
15.txt | AC | 22 ms | 3712 KB |
16.txt | AC | 22 ms | 3712 KB |
17.txt | AC | 22 ms | 3712 KB |
18.txt | AC | 1 ms | 256 KB |
19.txt | AC | 1 ms | 256 KB |
20.txt | AC | 1 ms | 256 KB |
21.txt | AC | 1 ms | 256 KB |
22.txt | AC | 1 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |