Submission #844357

# Submission time Handle Problem Language Result Execution time Memory
844357 2023-09-05T12:38:11 Z matan A Plus B (IOI23_aplusb) C++17
Compilation error
0 ms 0 KB
#include <vector>
#include <algorithm>
#include <queue>

std::vector<int> smallest_sums(int N, std::vector<int> A, std::vector<int> B){
  std::vector<int> C(N);
  std::vector<int> CC_index(N, 0);
  std::vector<int> C(N);
  std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, std::greater<std::pair<int, int>>> pq;
  for (int i = 0; i < N; i++) {
    pq.push({A[i] + B[0], 0});
  }
  int k = 0;
  while (k < N) {
    auto [sum, j] = pq.top();
    pq.pop();
    C[k++] = sum;
    if (j < N - 1) {
      pq.push({sum - B[j] + B[j + 1], j + 1});
    }
  }
  return C;
}

Compilation message

aplusb.cpp: In function 'std::vector<int> smallest_sums(int, std::vector<int>, std::vector<int>)':
aplusb.cpp:8:20: error: redeclaration of 'std::vector<int> C'
    8 |   std::vector<int> C(N);
      |                    ^
aplusb.cpp:6:20: note: 'std::vector<int> C' previously declared here
    6 |   std::vector<int> C(N);
      |                    ^