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>
#define all(v) ((v).begin(),(v).end())
#define ll long long
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll mxN = 1e5 + 2;
using namespace std;
struct number{
int val,iA,iB;
};
bool operator<(number a,number b){
return a.val < b.val;
}
vector<int> smallest_sums(int N, vector<int> A, vector<int> B) {
vector<int>ans;
multiset<number>s;
for(int i = 0;i < N;i++){
s.insert({A[0] + B[i],0,i});
}
for(int i =0;i < N;i++){
ans.push_back((*(s.begin())).val);
int iA = (*(s.begin())).iA;
int iB = (*(s.begin())).iB;
s.erase(s.begin());
s.insert({A[iA + 1] + B[iB],iA + 1,iB});
// cout<<A[iA + 1] + B[iB]<<' '<<iA + 1<<' '<<iB<<'\n';
}
return ans;
}
//
// int main() {
// int N;
// assert(1 == scanf("%d", &N));
// std::vector<int> A(N);
// for (int i = 0; i < N; ++i)
// assert(1 == scanf("%d", &A[i]));
// std::vector<int> B(N);
// for (int i = 0; i < N; ++i)
// assert(1 == scanf("%d", &B[i]));
//
// fclose(stdin);
//
// std::vector<int> res = smallest_sums(N, A, B);
//
// int n = res.size();
// for (int i = 0; i < n; ++i) {
// if (i > 0)
// printf(" ");
// printf("%d", res[i]);
// }
// printf("\n");
// fclose(stdout);
//
// 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... |