# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1092201 | 2024-09-23T14:21:17 Z | Luvidi | A Plus B (IOI23_aplusb) | C++17 | 0 ms | 0 KB |
std::vector<int> smallest_sums(int n, std::vector<int> a, std::vector<int> b) { long long l=0,r=2e9; while(l<r){ long long m=(l+r)/2,cnt=0,idx=n-1; for(int i=0;i<n;i++){ while(idx>=0&&a[i]+b[idx]>m)idx--; cnt+=idx+1; } if(cnt>=n)r=m; else l=m+1; } vector<int> ans; for(int i=0;i<n;i++){ for(int j=0;j<n&&a[i]+b[j]<l;j++){ ans.push_back(a[i]+b[j]); } } sort(ans.begin(),ans.end()); while(ans.size()<n)ans.push_back(l); return ans; }