# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
846004 | Mohamed_Kachef06 | A Plus B (IOI23_aplusb) | C++17 | 87 ms | 2628 KiB |
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;
typedef long long ll;
#define pb push_back
vector<int> smallest_sums(int n , vector<int> a, vector<int> b){
ll l = 0 , r = 2e9 , md;
while(l<=r){
md = (l+r)/2;
ll cnt =0 ;
for (int i = 0 ; i<n ; i++){
if (md >= a[i]) cnt+=lower_bound(b.begin() , b.end() , md - a[i]) - b.begin();
}
if (cnt < n) l = md+1;
else r = md-1;
}
ll ans = l-1;
vector<int> c;
for (int i = 0 ; i<n ; i++){
for (int j = 0 ; j<n ; j++){
if (a[i] + b[j] < ans) c.pb(a[i] + b[j]);
else break;
}
}
while(c.size() < n) c.pb(ans);
sort(c.begin() , c.end());
return c;
}
// signed main(){
// int n ; cin >> n;
// vector<int> a(n) , b(n);
// for (int i =0 ; i <n ; i++) cin >> a[i];
// for (int i = 0 ; i<n ; i++) cin >> b[i];
// vector<int> c = smallest_sums(n , a , b);
// for (auto i : c) cout << i << ' ';
// }
Compilation message (stderr)
# | 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... |