Submission #883742

#TimeUsernameProblemLanguageResultExecution timeMemory
883742MattTheNubA Plus B (IOI23_aplusb)C++17
100 / 100
48 ms5936 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<int2, v<int2>, greater<int2>> 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[p] + 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...