답안 #880266

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
880266 2023-11-29T05:01:22 Z Mardonbekhazratov A Plus B (IOI23_aplusb) C++17
10 / 100
1 ms 348 KB
#include "aplusb.h"
#include<bits/stdc++.h>
using namespace std;
 
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

aplusb.cpp: In function 'std::vector<int> smallest_sums(int, std::vector<int>, std::vector<int>)':
aplusb.cpp:8:13: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
    8 |  int l=-1,r=1e18;
      |             ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 -