Submission #883741

#TimeUsernameProblemLanguageResultExecution timeMemory
883741MattTheNubA Plus B (IOI23_aplusb)C++17
10 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; template <class T> using v = vector<T>; #ifdef EVAL #define dbg(...) #define dbg2d(...) #else istream &__cin = cin; #include "../../debug.h" __cinwrapper __cin_wrapper; #include "../../debug.cpp" #endif #include "aplusb.h" using ll = long long; using int2 = pair<int, int>; using ll2 = pair<ll, ll>; std::vector<int> smallest_sums(int N, std::vector<int> A, std::vector<int> B) { v<int> ptr(N); priority_queue<ll2, v<ll2>, greater<ll2>> vals; for (int i = 0; i < N; i++) { vals.push({A[i] + B[0], i}); } v<int> ans; for (int i = 0; i < N; i++) { auto [v, p] = vals.top(); vals.pop(); ans.push_back(v); if (++ptr[p] < N) { vals.push({A[i] + B[ptr[p]], p}); } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...