Submission #1518297
Source Code Expand
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
freopen((s+".in").c_str(),"r",stdin);
freopen((s+".out").c_str(),"w",stdout);
}
const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=1e5+7;
int a[N],b[N],na,nb,n;
int main(){
scanf("%d",&n);
rep(i,1,n){
int v;
scanf("%d",&v);
if(i&1) a[++na]=v;
else b[++nb]=v;
}
sort(a+1,a+na+1);
sort(b+1,b+nb+1);
ll ans=0,pos=0;
rep(i,1,nb){
while(pos<na&&a[pos+1]<b[i]) ++pos;
ans+=abs(i-pos);
}
printf("%lld\n",ans);
return 0;
}
Submission Info
Submission Time
2017-08-18 10:51:16+0900
Task
C - BBuBBBlesort!
User
zyding
Language
C++14 (GCC 5.4.1)
Score
0
Code Size
1808 Byte
Status
WA
Exec Time
19 ms
Memory
640 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:58:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:61:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&v);
^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
0 / 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
WA
19 ms
640 KB
02.txt
WA
19 ms
640 KB
03.txt
WA
19 ms
640 KB
04.txt
WA
19 ms
640 KB
05.txt
WA
17 ms
640 KB
06.txt
WA
17 ms
640 KB
07.txt
WA
17 ms
640 KB
08.txt
AC
12 ms
640 KB
09.txt
AC
12 ms
640 KB
10.txt
AC
11 ms
640 KB
11.txt
AC
11 ms
640 KB
12.txt
AC
12 ms
640 KB
13.txt
AC
12 ms
640 KB
14.txt
AC
16 ms
640 KB
15.txt
AC
16 ms
640 KB
16.txt
AC
16 ms
640 KB
17.txt
AC
16 ms
640 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