Submission #844358

#TimeUsernameProblemLanguageResultExecution timeMemory
844358matanA Plus B (IOI23_aplusb)C++17
100 / 100
48 ms3540 KiB
#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::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;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...