結果
問題 |
No.482 あなたの名は
|
ユーザー |
|
提出日時 | 2017-03-21 00:15:32 |
言語 | Java (openjdk 23) |
結果 |
RE
|
実行時間 | - |
コード長 | 835 bytes |
コンパイル時間 | 3,642 ms |
コンパイル使用メモリ | 79,572 KB |
実行使用メモリ | 88,288 KB |
最終ジャッジ日時 | 2024-07-05 04:40:43 |
合計ジャッジ時間 | 10,010 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 RE * 2 TLE * 1 -- * 15 |
ソースコード
import java.util.ArrayList; import java.util.Scanner; public class YourName { static ArrayList<Integer> list = new ArrayList<>(); static ArrayList<Integer> cut = new ArrayList<>(); static long K; static int N; public static void main(String[] args) { Scanner s = new Scanner(System.in); N = s.nextInt(); K = s.nextLong(); for(int i = 0;i<N;i++){ list.add(s.nextInt()); cut.add(i); } s.close(); for(int i = 0;i<cut.size();i++){ swtch(cut.get(i)); if(i>=cut.size()){ break; } } if(K > 0&&K%2 == 0){ K = 0; } if(K == 0) System.out.println("YES"); else System.out.println("NO"); } static void swtch(int i){ if(i+1 != list.get(i)){ int t = list.indexOf(i+1); list.set(t, list.get(i)); list.set(i, i+1); cut.remove(cut.indexOf(i+1)); swtch(t); K--; } } }