結果
問題 | No.482 あなたの名は |
ユーザー |
![]() |
提出日時 | 2017-02-10 22:53:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 590 bytes |
コンパイル時間 | 2,375 ms |
コンパイル使用メモリ | 165,772 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-28 08:51:16 |
合計ジャッジ時間 | 3,617 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 WA * 10 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { cin.tie(0); ios::sync_with_stdio(false); ll N, K; cin >> N >> K; ll sum = 0; for(int i = 0; i < N; i++) { int d; cin >> d; d--; if(i != d) sum++; } if(sum == 0) { if(K % 2 == 0) { cout << "YES" << endl; } else { cout << "NO" << endl; } } else if(sum <= 3) { if(sum - 1 <= K && K % 2 != sum % 2) { cout << "YES" << endl; } else { cout << "NO" << endl; } } else { if(sum - 1 <= K) { cout << "YES" << endl; } else { cout << "NO" << endl; } } }