This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
#include "aplusb.h"
using namespace std;
#define ff first
#define ss second
vector<int> smallest_sums(int n, vector<int> a, vector<int> b){
set<pair<int, pair<int, int>>> s;
for(int i = 0; i < n; ++i)
s.insert({{a[i] + b.front()}, {i, 0}});
vector<int> ans;
while((int)ans.size() != n){
auto val = *s.begin();
ans.push_back(val.ff);
s.erase(val);
s.insert({a[val.ss.ff] + b[val.ss.ss + 1], {val.ss.ff, val.ss.ss + 1}});
}
return ans;
}
// int main(){
// // vector<int> kk = smallest_sums(2, {0, 2}, {1, 4});
// vector<int> kk = smallest_sums(3, {0, 2, 2}, {3, 5, 6});
// for(int i : kk)
// printf("%d ", i);
// return 0;
// }
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |