Submission #842622

# Submission time Handle Problem Language Result Execution time Memory
842622 2023-09-03T06:25:51 Z WLZ A Plus B (IOI23_aplusb) C++17
100 / 100
108 ms 10436 KB
#include "aplusb.h"
#include <bits/stdc++.h>
using namespace std;

std::vector<int> smallest_sums(int n, std::vector<int> a, std::vector<int> b) {
    sort(a.begin(), a.end()); sort(b.begin(), b.end());
    vector<int> ans;
    set< pair<int, int> > st = {};
    priority_queue< tuple<int, int, int>, vector< tuple<int, int, int> >, greater<> > pq; pq.push({a[0] + b[0], 0, 0});
    while ((int) ans.size() < n) {
        int x = get<0>(pq.top()), i = get<1>(pq.top()), j = get<2>(pq.top());
        pq.pop();
        if (st.count({i, j})) continue;
        st.insert({i, j});
        ans.push_back(x);
        if (i < n - 1) pq.push({a[i + 1] + b[j], i + 1, j});
        if (j < n - 1) pq.push({a[i] + b[j + 1], i, j + 1});
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 440 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 440 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 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 444 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 436 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 436 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 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 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 440 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 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 444 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 436 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 436 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 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 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 2 ms 480 KB Output is correct
28 Correct 1 ms 472 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 600 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 2 ms 604 KB Output is correct
35 Correct 2 ms 604 KB Output is correct
36 Correct 2 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 440 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 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 444 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 436 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 436 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 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 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 2 ms 480 KB Output is correct
28 Correct 1 ms 472 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 600 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 2 ms 604 KB Output is correct
35 Correct 2 ms 604 KB Output is correct
36 Correct 2 ms 600 KB Output is correct
37 Correct 11 ms 2140 KB Output is correct
38 Correct 48 ms 8072 KB Output is correct
39 Correct 49 ms 7292 KB Output is correct
40 Correct 50 ms 7236 KB Output is correct
41 Correct 70 ms 9440 KB Output is correct
42 Correct 69 ms 9576 KB Output is correct
43 Correct 62 ms 9448 KB Output is correct
44 Correct 13 ms 2268 KB Output is correct
45 Correct 52 ms 7092 KB Output is correct
46 Correct 70 ms 7020 KB Output is correct
47 Correct 52 ms 6952 KB Output is correct
48 Correct 65 ms 9348 KB Output is correct
49 Correct 64 ms 10436 KB Output is correct
50 Correct 60 ms 9480 KB Output is correct
51 Correct 108 ms 8140 KB Output is correct
52 Correct 95 ms 8080 KB Output is correct
53 Correct 88 ms 8180 KB Output is correct