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>
using namespace std;
#define vi vector<int>
bool check(int s, vi a, vi b){
int n = a.size();
int prs = 0;
int j = n-1;
for (int i=0; i<n; i++){
for (; j>=0 && b[j]+a[i]>s; j--) ;
prs += j+1;
}
return prs>=n;
}
vi smallest_sums(int n, vi a, vi b){
int l = 0, r = 2e9+7;
while (l<r){
int m = (l+r)/2;
if (check(m, a, b)) r = m;
else l = m+1;
}
vi ans(n,0);
int ind = 0;
for (int i=0; i<n; i++){
for (int j=0; j<n && a[i]+b[j]<l; j++) ans[ind++] = a[i] + b[j];
}
while (ind < n) ans[ind++] = l;
sort(ans.begin(), ans.end());
return ans;
}
# | 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... |