답안 #877682

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
877682 2023-11-23T12:42:09 Z eldorbek_008 A Plus B (IOI23_aplusb) C++17
컴파일 오류
0 ms 0 KB
#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(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

aplusb.cpp: In function 'std::vector<int> smallest_sums(std::vector<int>, std::vector<int>)':
aplusb.cpp:45:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |    if ((int)C.size() == A.size()) {
      |        ~~~~~~~~~~~~~~^~~~~~~~~~~
/usr/bin/ld: /tmp/ccaBn39j.o: in function `main':
grader.cpp:(.text.startup+0x271): undefined reference to `smallest_sums(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status