2016年11月10日 星期四

TIOJ 1667 - reversed

http://tioj.infor.org/problems/1667

反正範圍這麼小 就別用merge sort自虐了(?



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#include<stdio.h>
int main(){
    int n;
    int a[103];
    while(scanf("%d",&n)!=EOF){
        int ans=0;
        for(int i=0;i<n;i++){
            scanf("%d",a+i);
            for(int j=0;j<i;j++){
                if(a[j]>a[i])ans++;
            }
        }
        printf("%d\n",ans);
    }
}

沒有留言:

張貼留言