結果
| 問題 |
No.482 あなたの名は
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-21 19:44:32 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 525 bytes |
| コンパイル時間 | 723 ms |
| コンパイル使用メモリ | 68,232 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-09-21 19:44:34 |
| 合計ジャッジ時間 | 2,576 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 WA * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | scanf("%d%lld", &n, &k);
| ~~~~~^~~~~~~~~~~~~~~~~~
main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d", &x);
| ~~~~~^~~~~~~~~~
ソースコード
#include <iostream>
using namespace std;
typedef long long LL;
int n, cnt;
LL k;
int main() {
scanf("%d%lld", &n, &k);
for (int i = 1, x; i <= n; ++i) {
scanf("%d", &x);
if (x != i) ++cnt;
}
if (cnt == 0) {
puts(k % 2 == 0 && k >= 2 ? "YES" : "NO");
} else if (cnt == 2) {
puts(k % 2 == 1 ? "YES" : "NO");
} else if (cnt == 3) {
puts(k % 2 == 0 && k >= 2 ? "YES" : "NO");
} else {
puts(k >= (cnt + 1) / 2 ? "YES" : "NO");
}
return 0;
}