結果

問題 No.699 ペアでチームを作ろう2
ユーザー GrenacheGrenache
提出日時 2018-09-22 18:35:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 262 ms / 1,000 ms
コード長 1,597 bytes
コンパイル時間 5,240 ms
コンパイル使用メモリ 76,076 KB
実行使用メモリ 60,448 KB
最終ジャッジ日時 2023-09-25 12:55:00
合計ジャッジ時間 9,394 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,956 KB
testcase_01 AC 126 ms
54,236 KB
testcase_02 AC 137 ms
55,496 KB
testcase_03 AC 126 ms
55,476 KB
testcase_04 AC 193 ms
59,116 KB
testcase_05 AC 254 ms
59,960 KB
testcase_06 AC 257 ms
60,208 KB
testcase_07 AC 255 ms
59,896 KB
testcase_08 AC 261 ms
60,368 KB
testcase_09 AC 254 ms
60,192 KB
testcase_10 AC 258 ms
60,084 KB
testcase_11 AC 261 ms
60,448 KB
testcase_12 AC 256 ms
60,068 KB
testcase_13 AC 257 ms
60,012 KB
testcase_14 AC 262 ms
60,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder699_1 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		
		long max = 0;

		Deque<List<Integer>> st = new ArrayDeque<>();
		List<Integer> ltmp = new ArrayList<>(n + 1);
		for (int i = 0; i < n; i++) {
			ltmp.add(i);
		}
		ltmp.add(1);
		st.push(ltmp);
		@SuppressWarnings("unused")
		int cnt = 0;
		while (!st.isEmpty()) {
			List<Integer> e = st.pop();
			int size = e.get(n);

			if (size >= n) {
//				pr.println(e);
				cnt++;

				long tmp = 0;
				long tmp2 = 0;
				for (int i = 0; i < n; i++) {
					if (i % 2 == 0) {
						tmp2 += a[e.get(i)];
					} else {
						tmp2 += a[e.get(i)];
						tmp ^= tmp2;
						tmp2 = 0;
					}
				}
				
				max = Math.max(max, tmp);
			} else {
				for (int i = size; i < n; i++) {
					List<Integer> ee = new ArrayList<>(e);
					int tmp = ee.get(size); ee.set(size, ee.get(i)); ee.set(i, tmp);
					ee.set(n, ee.get(n) + 2);
					
					st.push(ee);
				}
			}
		}

//		<pr.println(cnt);
		pr.println(max);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}
0