Submission #1986266


Source Code Expand

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  cin >> N;
  int n = pow(2, N);
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];

  for (int i = 1; i < n; i *= 2) {
    for (int j = 0; j < n - 1; j += i) {
      if (a[j] > a[j+i]) {
        a[j] = a[j] - a[j+i];
      } else if (a[j] < a[j+i]) {
        a[j] = a[j+i] - a[j];
      }
    }
  }

  // 解答
  cout << a[0] << endl;

  return 0;
}

Submission Info

Submission Time
Task C - Kode Festival
User university
Language C++14 (GCC 5.4.1)
Score 100
Code Size 870 Byte
Status AC
Exec Time 113 ms
Memory 1280 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 2
AC × 23
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All sample_01.txt, sample_02.txt, sample_01.txt, sample_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
subtask1_01.txt AC 1 ms 256 KB
subtask1_02.txt AC 1 ms 256 KB
subtask1_03.txt AC 1 ms 256 KB
subtask1_04.txt AC 1 ms 256 KB
subtask1_05.txt AC 8 ms 256 KB
subtask1_06.txt AC 1 ms 256 KB
subtask1_07.txt AC 14 ms 384 KB
subtask1_08.txt AC 53 ms 768 KB
subtask1_09.txt AC 2 ms 256 KB
subtask1_10.txt AC 105 ms 1280 KB
subtask1_11.txt AC 105 ms 1280 KB
subtask1_12.txt AC 105 ms 1280 KB
subtask1_13.txt AC 105 ms 1280 KB
subtask1_14.txt AC 106 ms 1280 KB
subtask1_15.txt AC 105 ms 1280 KB
subtask1_16.txt AC 113 ms 1280 KB
subtask1_17.txt AC 113 ms 1280 KB
subtask1_18.txt AC 105 ms 1280 KB
subtask1_19.txt AC 106 ms 1280 KB