Submission #2781009


Source Code Expand

Copy
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll N;
  cin >> N;
  ll A[1LL << 18];
  REP(i, 0, 1LL << N) scanf("%lld", A + i);

  ll ans = 0;
  REP(k, 1, 1LL << N) {
    ll p = 0, q = 0;
    ll i = k;
    do {
      ll w = max({ p, q, A[i] });
      q = p + q + A[i] - w - min({ p, q, A[i] });
      p = w;
      i = (i - 1) & k;
    } while(i != k);
    ans = max(ans, p + q);
    printf("%lld\n", ans);
  }
}

Submission Info

Submission Time
Task E - Or Plus Max
User kshinya
Language C++14 (GCC 5.4.1)
Score 700
Code Size 537 Byte
Status
Exec Time 1521 ms
Memory 5120 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:10:43: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   REP(i, 0, 1LL << N) scanf("%lld", A + i);
                                           ^

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 700 / 700 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 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB
subtask_1_01.txt 1 ms 256 KB
subtask_1_02.txt 1 ms 256 KB
subtask_1_03.txt 56 ms 640 KB
subtask_1_04.txt 2 ms 256 KB
subtask_1_05.txt 1 ms 256 KB
subtask_1_06.txt 8 ms 384 KB
subtask_1_07.txt 8 ms 384 KB
subtask_1_08.txt 1 ms 256 KB
subtask_1_09.txt 1 ms 256 KB
subtask_1_10.txt 20 ms 512 KB
subtask_1_11.txt 1 ms 256 KB
subtask_1_12.txt 57 ms 896 KB
subtask_1_13.txt 1 ms 256 KB
subtask_1_14.txt 1493 ms 5120 KB
subtask_1_15.txt 1 ms 256 KB
subtask_1_16.txt 1505 ms 5120 KB
subtask_1_17.txt 1475 ms 3584 KB
subtask_1_18.txt 1486 ms 4992 KB
subtask_1_19.txt 1507 ms 5120 KB
subtask_1_20.txt 1499 ms 5120 KB
subtask_1_21.txt 1504 ms 5120 KB
subtask_1_22.txt 1506 ms 5120 KB
subtask_1_23.txt 1512 ms 5120 KB
subtask_1_24.txt 1476 ms 3584 KB
subtask_1_25.txt 1481 ms 4992 KB
subtask_1_26.txt 1521 ms 5120 KB
subtask_1_27.txt 1518 ms 5120 KB
subtask_1_28.txt 1509 ms 5120 KB
subtask_1_29.txt 1481 ms 5120 KB