답안 #877683

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
877683 2023-11-23T12:43:53 Z eldorbek_008 A Plus B (IOI23_aplusb) C++17
30 / 100
1 ms 600 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(int N, 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(int, 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()) {
      |        ~~~~~~~~~~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 440 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 592 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 440 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 592 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 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 Incorrect 1 ms 348 KB 1st lines differ - on the 63rd token, expected: '1401', found: '1404'
24 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 440 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 592 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 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 Incorrect 1 ms 348 KB 1st lines differ - on the 63rd token, expected: '1401', found: '1404'
24 Halted 0 ms 0 KB -