Submission #2781006


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("%d", 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("%d\n", ans);
  }
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:10:40: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘ll* {aka long long int*}’ [-Wformat=]
   REP(i, 0, 1LL << N) scanf("%d", A + i);
                                        ^
./Main.cpp:23:23: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘ll {aka long long int}’ [-Wformat=]
     printf("%d\n", ans);
                       ^
./Main.cpp:10:41: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   REP(i, 0, 1LL << N) scanf("%d", A + i);
                                         ^

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 0 / 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 1511 ms 5120 KB
subtask_1_15.txt 1 ms 256 KB
subtask_1_16.txt 1507 ms 5120 KB
subtask_1_17.txt 1493 ms 3584 KB
subtask_1_18.txt 1511 ms 4992 KB
subtask_1_19.txt 1508 ms 5120 KB
subtask_1_20.txt 1494 ms 5120 KB
subtask_1_21.txt 1504 ms 5120 KB
subtask_1_22.txt 1520 ms 5120 KB
subtask_1_23.txt 1522 ms 5120 KB
subtask_1_24.txt 1480 ms 3584 KB
subtask_1_25.txt 1500 ms 4992 KB
subtask_1_26.txt 1543 ms 5120 KB
subtask_1_27.txt 1514 ms 5120 KB
subtask_1_28.txt 1526 ms 5120 KB
subtask_1_29.txt 1528 ms 5120 KB