답안 #880265

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
880265 2023-11-29T05:00:49 Z Mardonbekhazratov A Plus B (IOI23_aplusb) C++17
컴파일 오류
0 ms 0 KB
#include "aplusb.h"
#define int long long
 
std::vector<int> smallest_sums(int N, std::vector<int> A, std::vector<int> B) {
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	int l=-1,r=1e18;
	while(r-l>1){
		int mid=(l+r)/2;
		int ans=0;
		for(int i=0;i<N;i++){
			ans+=upper_bound(B.begin(),B.end(),mid-A[i])-B.begin();
		}
		if(ans>=N) r=mid;
		else l=mid;
	}
	std::vector<int> ans(N);
	int j=0;
	for(int i=0;i<N;i++){
		int pos=std::lower_bound(B.begin(),B.end(),r-A[i])-B.begin();
		for(int k=0;k<pos;k++){
			ans[j++]=A[i]+B[k];
		}
	}
	while(j<N) ans[j++]=r;
	sort(ans.begin(),ans.end());
	return ans;
}

Compilation message

aplusb.cpp: In function 'std::vector<long long int> smallest_sums(long long int, std::vector<long long int>, std::vector<long long int>)':
aplusb.cpp:5:2: error: 'sort' was not declared in this scope; did you mean 'short'?
    5 |  sort(A.begin(),A.end());
      |  ^~~~
      |  short
aplusb.cpp:12:9: error: 'upper_bound' was not declared in this scope
   12 |    ans+=upper_bound(B.begin(),B.end(),mid-A[i])-B.begin();
      |         ^~~~~~~~~~~