#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 |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Execution timed out |
1079 ms |
212 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Execution timed out |
1079 ms |
212 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Execution timed out |
1079 ms |
212 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Execution timed out |
1079 ms |
212 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |