結果
問題 |
No.5001 排他的論理和でランニング
|
ユーザー |
![]() |
提出日時 | 2018-03-16 22:40:55 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 976 bytes |
コンパイル時間 | 2,269 ms |
実行使用メモリ | 56,276 KB |
スコア | 2,887,472 |
最終ジャッジ日時 | 2020-03-12 19:26:16 |
ジャッジサーバーID (参考情報) |
judge9 / |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 WA * 47 |
ソースコード
import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); final int M = sc.nextInt(); long[] array = new long[N]; for(int i = 0; i < N; i++){ array[i] = sc.nextLong(); } Arrays.sort(array); boolean[] used = new boolean[N]; long max = 0; for(int i = 0; i < M; i++){ used[i] = true; max ^= array[(N - 1) - i]; } for(int x = 0; x < 10000000; x++){ final int fst = (int)(Math.random() * N); final int snd = (int)(Math.random() * N); final long next_max = max ^ array[fst] ^ array[snd]; if(next_max > max){ max = next_max; used[fst] = !used[fst]; used[snd] = !used[snd]; } } for(int i = 0; i < N; i++){ if(!used[i]){ continue; } System.out.print((i == 0 ? "" : " ") + (array[i])); } System.out.println(); } }