답안 #954000

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
954000 2024-03-27T05:11:42 Z pcc A Plus B (IOI23_aplusb) C++17
100 / 100
72 ms 4568 KB
#include "aplusb.h"
#include <bits/stdc++.h>
using namespace std;

long long f(int lim,vector<int> &A,vector<int>& B){
	long long re = 0;
	for(int i = 0;i<A.size();i++){
		auto pos = upper_bound(B.begin(),B.end(),lim-A[i])-B.begin();
		re += pos;
	}
	return re;
}

std::vector<int> smallest_sums(int N, std::vector<int> A, std::vector<int> B) {
	int l = 0,r = 2e9;
	while(l != r){
		int mid = (1ll*l+r)>>1;
		if(f(mid,A,B)>=N)r = mid;
		else l = mid+1;
	}
	vector<int> re;
	for(int i = 0;i<A.size();i++){
		for(int j = 0;j<B.size()&&A[i]+B[j]<l;j++)re.push_back(A[i]+B[j]);
	}
	while(re.size()<N)re.push_back(l);
	sort(re.begin(),re.end());
	return re;
}

Compilation message

aplusb.cpp: In function 'long long int f(int, std::vector<int>&, std::vector<int>&)':
aplusb.cpp:7:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |  for(int i = 0;i<A.size();i++){
      |                ~^~~~~~~~~
aplusb.cpp: In function 'std::vector<int> smallest_sums(int, std::vector<int>, std::vector<int>)':
aplusb.cpp:22:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  for(int i = 0;i<A.size();i++){
      |                ~^~~~~~~~~
aplusb.cpp:23:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   for(int j = 0;j<B.size()&&A[i]+B[j]<l;j++)re.push_back(A[i]+B[j]);
      |                 ~^~~~~~~~~
aplusb.cpp:25:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |  while(re.size()<N)re.push_back(l);
      |        ~~~~~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 432 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 600 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 432 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 600 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 2 ms 344 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 444 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 544 KB Output is correct
34 Correct 2 ms 348 KB Output is correct
35 Correct 2 ms 488 KB Output is correct
36 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 432 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 600 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 2 ms 344 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 444 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 544 KB Output is correct
34 Correct 2 ms 348 KB Output is correct
35 Correct 2 ms 488 KB Output is correct
36 Correct 2 ms 348 KB Output is correct
37 Correct 13 ms 1216 KB Output is correct
38 Correct 45 ms 3280 KB Output is correct
39 Correct 46 ms 3648 KB Output is correct
40 Correct 44 ms 3532 KB Output is correct
41 Correct 61 ms 4568 KB Output is correct
42 Correct 59 ms 4440 KB Output is correct
43 Correct 71 ms 4044 KB Output is correct
44 Correct 12 ms 1216 KB Output is correct
45 Correct 48 ms 3652 KB Output is correct
46 Correct 49 ms 3588 KB Output is correct
47 Correct 47 ms 3636 KB Output is correct
48 Correct 61 ms 4536 KB Output is correct
49 Correct 62 ms 4300 KB Output is correct
50 Correct 60 ms 4056 KB Output is correct
51 Correct 72 ms 3792 KB Output is correct
52 Correct 67 ms 3784 KB Output is correct
53 Correct 65 ms 3788 KB Output is correct