結果
| 問題 |
No.482 あなたの名は
|
| コンテスト | |
| ユーザー |
splatatsugoma
|
| 提出日時 | 2017-02-10 23:07:02 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 798 bytes |
| コンパイル時間 | 856 ms |
| コンパイル使用メモリ | 20,608 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2024-12-28 09:34:13 |
| 合計ジャッジ時間 | 47,881 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 13 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]);
| ^~~~~~~~~~~~~~~~~~~
ソースコード
#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;
}
splatatsugoma