Submission #2777271


Source Code Expand

Copy
#include <stdio.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
typedef long long ll;

ll max(ll x, ll y, ll z) {
  if(x >= y && x >= z) return x;
  return y >= z ? y : z;
}

ll min(ll x, ll y, ll z) {
  if(x <= y && x <= z) return x;
  return y <= z ? y : z;
}

int main(void) {
  ll N;
  scanf("%lld", &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, 0);
    printf("%lld\n", ans);
  }
}

Submission Info

Submission Time
Task E - Or Plus Max
User kshinya
Language C (Clang 3.8.0)
Score 700
Code Size 701 Byte
Status
Exec Time 1685 ms
Memory 5120 KB

Judge Result

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 128 KB
sample_02.txt 1 ms 128 KB
sample_03.txt 1 ms 128 KB
subtask_1_01.txt 1 ms 128 KB
subtask_1_02.txt 1 ms 128 KB
subtask_1_03.txt 58 ms 640 KB
subtask_1_04.txt 1 ms 128 KB
subtask_1_05.txt 1 ms 128 KB
subtask_1_06.txt 8 ms 256 KB
subtask_1_07.txt 8 ms 384 KB
subtask_1_08.txt 1 ms 128 KB
subtask_1_09.txt 1 ms 128 KB
subtask_1_10.txt 20 ms 384 KB
subtask_1_11.txt 1 ms 128 KB
subtask_1_12.txt 59 ms 768 KB
subtask_1_13.txt 1 ms 128 KB
subtask_1_14.txt 1671 ms 4992 KB
subtask_1_15.txt 1 ms 128 KB
subtask_1_16.txt 1679 ms 4992 KB
subtask_1_17.txt 1640 ms 3456 KB
subtask_1_18.txt 1675 ms 4864 KB
subtask_1_19.txt 1646 ms 4992 KB
subtask_1_20.txt 1636 ms 5120 KB
subtask_1_21.txt 1641 ms 4992 KB
subtask_1_22.txt 1675 ms 4992 KB
subtask_1_23.txt 1685 ms 4992 KB
subtask_1_24.txt 1622 ms 3456 KB
subtask_1_25.txt 1636 ms 4864 KB
subtask_1_26.txt 1669 ms 4992 KB
subtask_1_27.txt 1647 ms 4992 KB
subtask_1_28.txt 1650 ms 5120 KB
subtask_1_29.txt 1660 ms 4992 KB