Submission #2772610


Source Code Expand

Copy
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(1 << n), first(1 << n), second(1 << n, -1);
	for (int i = 0; i < 1 << n; ++i) {
		cin >> a[i];
		first[i] = i;
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 1 << n; ++j) {
			if ((j >> i) & 1) {
				int k = j - (1 << i);
				if (a[first[j]] < a[first[k]]) {
					second[j] = (a[first[j]] < (second[k] != -1 ? a[second[k]] : -1) ? second[k] : first[j]);
					first[j] = first[k];
				}
				else if (a[first[k]] > (second[j] != -1 ? a[second[j]] : -1)) {
					second[j] = first[k];
				}
			}
		}
	}
	int ret = 0;
	for (int i = 1; i < 1 << n; ++i) {
		ret = max(ret, a[first[i]] + a[second[i]]);
		cout << ret << '\n';
	}
	return 0;
}

Submission Info

Submission Time
Task E - Or Plus Max
User square1001
Language C++14 (GCC 5.4.1)
Score 700
Code Size 851 Byte
Status AC
Exec Time 71 ms
Memory 6144 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 3
AC × 35
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt, subtask_1_19.txt, subtask_1_20.txt, subtask_1_21.txt, subtask_1_22.txt, subtask_1_23.txt, subtask_1_24.txt, subtask_1_25.txt, subtask_1_26.txt, subtask_1_27.txt, subtask_1_28.txt, subtask_1_29.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
subtask_1_01.txt AC 1 ms 256 KB
subtask_1_02.txt AC 1 ms 256 KB
subtask_1_03.txt AC 8 ms 768 KB
subtask_1_04.txt AC 1 ms 256 KB
subtask_1_05.txt AC 1 ms 256 KB
subtask_1_06.txt AC 3 ms 384 KB
subtask_1_07.txt AC 3 ms 384 KB
subtask_1_08.txt AC 1 ms 256 KB
subtask_1_09.txt AC 1 ms 256 KB
subtask_1_10.txt AC 4 ms 512 KB
subtask_1_11.txt AC 1 ms 256 KB
subtask_1_12.txt AC 8 ms 1024 KB
subtask_1_13.txt AC 1 ms 256 KB
subtask_1_14.txt AC 70 ms 6144 KB
subtask_1_15.txt AC 1 ms 256 KB
subtask_1_16.txt AC 70 ms 6144 KB
subtask_1_17.txt AC 58 ms 4608 KB
subtask_1_18.txt AC 57 ms 6016 KB
subtask_1_19.txt AC 57 ms 6144 KB
subtask_1_20.txt AC 68 ms 6144 KB
subtask_1_21.txt AC 71 ms 6144 KB
subtask_1_22.txt AC 70 ms 6144 KB
subtask_1_23.txt AC 70 ms 6144 KB
subtask_1_24.txt AC 58 ms 4608 KB
subtask_1_25.txt AC 57 ms 6016 KB
subtask_1_26.txt AC 58 ms 6144 KB
subtask_1_27.txt AC 68 ms 6144 KB
subtask_1_28.txt AC 70 ms 6144 KB
subtask_1_29.txt AC 70 ms 6144 KB