結果

問題 No.482 あなたの名は
ユーザー splatatsugoma
提出日時 2017-02-10 23:10:39
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 800 bytes
コンパイル時間 225 ms
コンパイル使用メモリ 21,248 KB
実行使用メモリ 13,772 KB
最終ジャッジ日時 2024-12-29 04:21:04
合計ジャッジ時間 47,050 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9 WA * 4 TLE * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:24:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |         scanf("%d",&N);
      |         ^~~~~~~~~~~~~~
main.c:25:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |         scanf("%d",&K);
      |         ^~~~~~~~~~~~~~
main.c:31:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |                 scanf("%d",&ary[i]);
      |                 ^~~~~~~~~~~~~~~~~~~

ソースコード

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