結果

問題 No.482 あなたの名は
ユーザー splatatsugomasplatatsugoma
提出日時 2017-02-10 23:07:02
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 798 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 24,192 KB
実行使用メモリ 6,804 KB
最終ジャッジ日時 2023-08-27 23:34:01
合計ジャッジ時間 4,244 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>

int bubblesort(int x[ ], int n)
{
    int i, j, temp,c=0;

    for (i = 0; i < n - 1; i++) {
        for (j = n - 1; j > i; j--) {
            if (x[j - 1] > x[j]) {  
                temp = x[j];        
                x[j] = x[j - 1];
                x[j - 1]= temp;
		c++;
            }
        }	
    }
	printf("%d",c);
	return c;
}


int main(){
	int i,N,K,ary[200000],ans,flag=0;
	scanf("%d",&N);
	scanf("%d",&K);
	
	//printf("%d",N);
	//printf("%d",K);

	for(i=0;i<N;i++){
		scanf("%d",&ary[i]);
	}
	/*for(i=0;i<N;i++){
		printf("%d",ary[i]);
	}*/
	ans=bubblesort(ary,N);
	if(ans<=K){
		if((K-ans)%2==0) flag=1;
		else if((K-ans)%2==1) flag=0;
	}else flag=2;
	
	if(flag==0) printf("NO\n");
	else if(flag==1) printf("YES\n");
	else if(flag==2) printf("NO\n");
	return 0;
}
0