結果
問題 |
No.482 あなたの名は
|
ユーザー |
![]() |
提出日時 | 2017-02-10 23:27:53 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 700 bytes |
コンパイル時間 | 3,360 ms |
コンパイル使用メモリ | 74,836 KB |
実行使用メモリ | 54,740 KB |
最終ジャッジ日時 | 2024-12-29 05:08:58 |
合計ジャッジ時間 | 17,680 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 13 |
ソースコード
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; i++){ D[i] = sc.nextInt(); } int c=0; for(int i=1; i<=N; i++){ if(i!=D[i]){ int tmp = D[i]; D[i] = D[tmp]; D[tmp] = tmp; c++; } } boolean b = true; if(c>K||K-c==1)b = false; if(b){ System.out.println("YES"); }else{ System.out.println("NO"); } } }