結果
| 問題 |
No.482 あなたの名は
|
| コンテスト | |
| ユーザー |
くれちー
|
| 提出日時 | 2017-02-12 21:13:12 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 833 bytes |
| コンパイル時間 | 188 ms |
| コンパイル使用メモリ | 23,424 KB |
| 実行使用メモリ | 13,636 KB |
| 最終ジャッジ日時 | 2024-12-29 16:58:01 |
| 合計ジャッジ時間 | 4,956 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 WA * 7 TLE * 1 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:35:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
35 | scanf("%d %lld", &n, &k);
| ^~~~~~~~~~~~~~~~~~~~~~~~
main.c:37:15: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
37 | rep(i, n) scanf("%d", &d[i]);
| ^~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define rep(i, n) for (i = 0; i < n; i++)
#define rrep(i, n) for (i = n; i >= 0; i--)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
long long cnt;
void swap(int *a, int *b) {
if (*a != *b) cnt++;
int tmp = *a;
*a = *b;
*b = tmp;
}
void sort(int *d, int s) {
int i, l = 1;
if (s < 2) return;
for (i = 1; i < s; i++) {
if (d[0] > d[i]) {
if (l != i) swap(&d[l], &d[i]);
l++;
}
}
if (l - 1 != 0) swap(&d[0], &d[l - 1]);
sort(d, l);
sort(d + l, s - l);
}
int main() {
int n; long long k;
scanf("%d %lld", &n, &k);
int d[200000], i;
rep(i, n) scanf("%d", &d[i]);
sort(d, n);
if (cnt > k) puts("NO");
else if ((k - cnt) % 2) puts("NO");
else puts("YES");
return 0;
}
くれちー