結果
問題 |
No.482 あなたの名は
|
ユーザー |
![]() |
提出日時 | 2017-07-09 18:19:32 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 570 bytes |
コンパイル時間 | 2,225 ms |
コンパイル使用メモリ | 74,832 KB |
実行使用メモリ | 51,828 KB |
最終ジャッジ日時 | 2024-10-07 04:42:52 |
合計ジャッジ時間 | 9,552 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | TLE * 1 -- * 2 |
other | -- * 28 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); long K = sc.nextLong(); int[] d = new int[N + 1]; for(int i = 1; i < N + 1; i++) { d[i] = sc.nextInt(); } long num = 0; for(int i = 1; i < N + 1; i++) { while(d[i] != i) { int temp = d[i]; d[i] = d[d[i]]; d[d[i]] = temp; num++; } } String ans = "NO"; if(num <= K && (K - num) % 2 == 0) ans = "YES"; System.out.println(ans); } }