Submission #1094321

# Submission time Handle Problem Language Result Execution time Memory
1094321 2024-09-29T10:35:25 Z Sunbae A Plus B (IOI23_aplusb) C++17
100 / 100
64 ms 4564 KB
#include <cstdio>
#include <vector>
#include <algorithm>
#include "aplusb.h"
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;
vector<int> smallest_sums(int n, vector<int> A, vector<int> B) {
	ll low = A[0] + B[0], high = A[n-1] + B[n-1], ans;
	while(low <= high){
		ll mid = low + ((high-low)>>1), cnt = 0;
		for(int i = 0; i<n; ++i){
			cnt += upper_bound(B.begin(), B.end(), mid-A[i]) - B.begin();
		}
		if(cnt >= n) high = mid-1, ans = mid;
		else low = mid+1;
	}
	vector<int> v;
	for(int i = 0, m = 0; i<n; ++i){
		for(int j = 0; A[i] + B[j] <= ans && j<n; ++j){
			v.push_back(A[i] + B[j]);
		}
	}
	sort(v.begin(), v.end());
	v.resize(n);
	return v;
}

Compilation message

aplusb.cpp: In function 'std::vector<int> smallest_sums(int, std::vector<int>, std::vector<int>)':
aplusb.cpp:19:17: warning: unused variable 'm' [-Wunused-variable]
   19 |  for(int i = 0, m = 0; i<n; ++i){
      |                 ^
aplusb.cpp:20:37: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   20 |   for(int j = 0; A[i] + B[j] <= ans && j<n; ++j){
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 2 ms 344 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 2 ms 344 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 11 ms 1268 KB Output is correct
38 Correct 41 ms 3280 KB Output is correct
39 Correct 40 ms 3532 KB Output is correct
40 Correct 40 ms 3536 KB Output is correct
41 Correct 56 ms 4556 KB Output is correct
42 Correct 63 ms 4564 KB Output is correct
43 Correct 51 ms 4048 KB Output is correct
44 Correct 11 ms 1220 KB Output is correct
45 Correct 51 ms 3448 KB Output is correct
46 Correct 42 ms 3544 KB Output is correct
47 Correct 54 ms 3444 KB Output is correct
48 Correct 59 ms 4560 KB Output is correct
49 Correct 55 ms 4304 KB Output is correct
50 Correct 64 ms 4056 KB Output is correct
51 Correct 40 ms 3788 KB Output is correct
52 Correct 42 ms 3800 KB Output is correct
53 Correct 41 ms 3788 KB Output is correct