답안 #1094320

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1094320 2024-09-29T10:34:16 Z Sunbae A Plus B (IOI23_aplusb) C++17
10 / 100
0 ms 348 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 += lower_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(n);
	for(int i = 0, m = 0; i<n; ++i){
		for(int j = 0; A[i] + B[j] <= ans && j<n; ++j){
			if(m < n) v[m++] = A[i] + B[j];
		}
	}
	sort(v.begin(), v.end());
	return v;
}

Compilation message

aplusb.cpp: In function 'std::vector<int> smallest_sums(int, std::vector<int>, std::vector<int>)':
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){
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB 1st lines differ - on the 2nd token, expected: '3', found: '4'
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB 1st lines differ - on the 2nd token, expected: '3', found: '4'
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB 1st lines differ - on the 2nd token, expected: '3', found: '4'
6 Halted 0 ms 0 KB -