結果

問題 No.482 あなたの名は
ユーザー splatatsugomasplatatsugoma
提出日時 2017-02-10 23:51:48
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,250 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 25,808 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 10:21:26
合計ジャッジ時間 2,138 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int count=0;

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 selectsort(int num[ ], int n){
    int i, j, k, min, temp,c=0;

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

void Swap(int x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}


void quicksort(int x[ ], int left, int right)
{
    int i, j;
    int pivot;


    i = left;                      
    j = right;                     

    pivot = x[(left + right) / 2]; 

    while (1) {                    

        while (x[i] < pivot)       
            i++;                   

        while (pivot < x[j])       
            j--;                   
        if (i >= j)                
            break;                 

        Swap(x, i, j); 
	count++;            
        i++;                       
        j--;
    }              

    if (left < i - 1)              
        quicksort(x, left, i - 1);   
    if (j + 1 <  right)           
        quicksort(x, j + 1, right);   
}

int main(){
	int i,N,K,ary[200000],cp[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]);
	}

	memcpy(cp,ary,sizeof(int)*N);
	quicksort(cp,0,N-1);
	/*for(i=0;i<N;i++){
		printf("%d ",cp[i]);
	}*/
	if(count<=K){
		if((K-count)%2==0) flag=1;
		else if((K-count)%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