# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
877683 | eldorbek_008 | A Plus B (IOI23_aplusb) | C++17 | 1 ms | 600 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 "aplusb.h"
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define all(x) (x).begin(), (x).end()
inline bool check(vector<int> A, vector<int> B, int x) {
int id = (int)A.size();
for (int i = 0; i < (int)A.size(); i++) {
for (int j = 0; j < (int)B.size(); j++) {
if (A[i] + B[j] <= x) {
--id;
} else break;
if (!id) return true;
}
}
return false;
}
vector<int> smallest_sums(int N, vector<int> A, vector<int> B) {
int l = 0, r = (int)2e9 + 1;
while (r - l > 1) {
int mid = (l + r) / 2;
if (check(A, B, mid)) r = mid;
else l = mid;
}
vector<int> C;
for (int i = 0; i < (int)A.size(); i++) {
for (int j = 0; j < (int)B.size(); j++) {
if (A[i] + B[j] <= r) {
C.push_back(A[i] + B[j]);
} else break;
if ((int)C.size() == A.size()) {
break;
}
}
// if ((int)C.size() == (int)A.size()) break;
}
sort(all(C));
C.resize((int)A.size());
return C;
}
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... |