Submission #4260556
Source Code Expand
#include<bits/stdc++.h> using namespace std; #define rg register #define ll long long inline ll read() { ll 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 { ll num,id; ll tot; }s[100503]; inline bool cmp(node a,node b) { return a.num<b.num; } ll ji,ou; int main() { n=read(); for(rg int i=1;i<=n;++i) { s[i].num=read(); s[i].id=i; } stable_sort(s+1,s+1+n,cmp); for(rg int i=1;i<=n;++i) { if(s[i].id%2==0)//站的是偶数位置 { if(i%2==0) { continue; } else//否则必将使用一次操作1 { ou++; } } else { if(i%2!=0) { continue; } else { ji++; } } } // ll ans=0; // for(rg int i=1;i<n;++i) // { // if(s[s[i].id].tot==0) // { // continue; // } // if(s[s[i].id].tot!=0&&s[s[i+1].id].tot!=0) // { // ans++; // s[s[i].id].tot=0; // s[s[i+1].id].tot=0; // } // else if(s[s[i].id].tot!=0&&s[s[i+1].id].tot==0) // { // ans++; // } //// cout<<i<<" "<<ans<<endl; // } // cout<<ans; ll h=min(ou,ji); cout<<h+abs(ou-ji); }
Submission Info
Submission Time | |
---|---|
Task | C - BBuBBBlesort! |
User | vjudge5 |
Language | C++14 (GCC 5.4.1) |
Score | 600 |
Code Size | 1252 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 | 3712 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 | 4736 KB |
07.txt | AC | 22 ms | 3712 KB |
08.txt | AC | 14 ms | 3712 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 | 4864 KB |
13.txt | AC | 14 ms | 3712 KB |
14.txt | AC | 21 ms | 3712 KB |
15.txt | AC | 21 ms | 3712 KB |
16.txt | AC | 21 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 |