답안 #849143

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
849143 2023-09-14T07:01:10 Z emad234 A Plus B (IOI23_aplusb) C++17
100 / 100
59 ms 8972 KB
#include <bits/stdc++.h>
#define all(v) ((v).begin(),(v).end())
#define ll long long
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll mxN = 1e5 + 2;
using namespace std;
struct number{
	int val,iA,iB;
};
bool operator<(number a,number b){
	return a.val < b.val;
}

vector<int> smallest_sums(int N, vector<int> A, vector<int> B) {
	vector<int>ans;
	multiset<number>s;
	for(int i = 0;i < N;i++){
		s.insert({A[0] + B[i],0,i});
	}
	for(int i =0;i < N;i++){
		ans.push_back((*(s.begin())).val);
		int iA = (*(s.begin())).iA;
		int iB = (*(s.begin())).iB;
		s.erase(s.begin());
		s.insert({A[iA + 1] + B[iB],iA + 1,iB});
		// cout<<A[iA + 1] + B[iB]<<' '<<iA + 1<<' '<<iB<<'\n';
	}
	return ans;
}

// 
// int main() {
// 	int N;
// 	assert(1 == scanf("%d", &N));
// 	std::vector<int> A(N);
// 	for (int i = 0; i < N; ++i)
// 		assert(1 == scanf("%d", &A[i]));
// 	std::vector<int> B(N);
// 	for (int i = 0; i < N; ++i)
// 		assert(1 == scanf("%d", &B[i]));
// 
// 	fclose(stdin);
// 
// 	std::vector<int> res = smallest_sums(N, A, B);
// 
// 	int n = res.size();
// 	for (int i = 0; i < n; ++i) {
// 		if (i > 0)
// 			printf(" ");
// 		printf("%d", res[i]);
// 	}
// 	printf("\n");
// 	fclose(stdout);
// 
// 	return 0;
// }
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 344 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 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 388 KB Output is correct
8 Correct 0 ms 344 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 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 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 344 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 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 388 KB Output is correct
8 Correct 0 ms 344 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 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 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 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 548 KB Output is correct
26 Correct 2 ms 600 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 440 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 604 KB Output is correct
34 Correct 1 ms 604 KB Output is correct
35 Correct 1 ms 604 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 388 KB Output is correct
8 Correct 0 ms 344 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 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 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 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 548 KB Output is correct
26 Correct 2 ms 600 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 440 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 604 KB Output is correct
34 Correct 1 ms 604 KB Output is correct
35 Correct 1 ms 604 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
37 Correct 11 ms 2140 KB Output is correct
38 Correct 43 ms 6856 KB Output is correct
39 Correct 44 ms 6788 KB Output is correct
40 Correct 48 ms 6860 KB Output is correct
41 Correct 54 ms 8972 KB Output is correct
42 Correct 56 ms 8892 KB Output is correct
43 Correct 59 ms 8696 KB Output is correct
44 Correct 10 ms 2136 KB Output is correct
45 Correct 43 ms 6784 KB Output is correct
46 Correct 42 ms 6864 KB Output is correct
47 Correct 40 ms 6868 KB Output is correct
48 Correct 57 ms 8892 KB Output is correct
49 Correct 52 ms 8892 KB Output is correct
50 Correct 51 ms 8656 KB Output is correct
51 Correct 57 ms 8744 KB Output is correct
52 Correct 57 ms 8656 KB Output is correct
53 Correct 55 ms 8868 KB Output is correct