Submission #880262

# Submission time Handle Problem Language Result Execution time Memory
880262 2023-11-29T04:57:55 Z Mardonbekhazratov A Plus B (IOI23_aplusb) C++17
Compilation error
0 ms 0 KB
#include "aplusb.h"
#include<bits/stdc++.h>
using namespace std;
#define int long long
 
vector<int> smallest_sums(int N, vector<int> A, 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;
	}
	vector<int> ans(N);
	int j=0;
	for(int i=0;i<N;i++){
		int pos=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

/usr/bin/ld: /tmp/ccqNjSWj.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