ank (38:02:43)
0 Comments
SettingFavorite
A
B
C
D
E
F
G
H
I
J
Submit
Status My Status
Time limit
1000 ms
Memory limit
65536 kB
OS
Linux
I - The Number of Inversions 


All Copyright Reserved ?2010-2017 Xu Han 
Server Time: 2017-12-19 14:02:47 CST

#12016314 | MyVj's solution for [Problem I]
Status
Compile Error
Length
478
Lang
C
Submitted
2017-12-19 14:02:14
Shared

code.c:1:22: fatal error: iostream: No such file or directory 
compilation terminated. 
Select Code
#include <iostream>  
#include <cstdio>  
#include <algorithm>
#define N 200001  
using namespace std; 
long long cnt=0;
long long b(long long a[],long long n){
	for(long long i=0;i<n;i++){
		for(long long j=n-1;j>i;j--){
			if( a[j] < a[j-1]){
				long long ax=a[j];
				a[j]=a[j-1];
				a[j-1]＝ax;
				cnt++;
			}
		}
	} 
	return cnt;
} 
int main() { 
	long long n;
	scanf("%ld",&n);
	long long a[N];
	for(long long i=0;i<n;i++){
		scanf("%ld",&a[i]);
	}
	cout<<b(a,n)<<"\n";
} 