-
Notifications
You must be signed in to change notification settings - Fork 0
/
P1631.cpp
68 lines (64 loc) · 1.64 KB
/
P1631.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
////
//// Created by lsk on 3/20/24.
////
//#include <cstdio>
//#include <cstdlib>
//#include <queue>
//#include <vector>
//
//#define pair_t std::pair<int, int>
//
//int main () {
// int n;
// scanf("%d", &n);
// int *seq1 = (int *) malloc(sizeof(int)*n);
// int *seq2 = (int *) malloc(sizeof(int)*n);
// std::priority_queue<pair_t, std::vector<pair_t>, std::greater<pair_t>> resultQueue;
// for(int i = 0; i < n; i++) {
// scanf("%d", &seq1[i]);
// }
// for(int i = 0; i < n; i++) {
// scanf("%d", &seq2[i]);
// }
// for (int i = 0; i < n; i++) {
// resultQueue.push(std::make_pair(seq1[i] + seq2[0], 0));
// }
// for (int i = 0; i < n; i++) {
// pair_t head = resultQueue.top();
// resultQueue.pop();
// printf("%d ", head.first);
// head.first;
// }
// free(seq1);
// free(seq2);
// printf("\n");
// return 0;
//}
#include <iostream>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#define mkpii(a, b) std::make_pair(a, b)
#define pii std::pair<int, int>
#define MAX 100010
int seq1[MAX] = {0};
int seq2[MAX] = {0};
int main() {
int n; std::cin >> n;
for (int i = 1; i <= n; i++) std::cin >> seq1[i];
for (int i = 1; i <= n; i++) std::cin >> seq2[i];
std::priority_queue<int, std::vector<int>, std::greater<>> queue;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
int sum = seq1[i] + seq2[j];
queue.push(sum);
if (i*j >= n) break;
}
}
for (int i = 0; i < n; i++) {
int e = queue.top();
std::cout << e << std::endl;
}
printf("\n");
}