# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
991940 | 2024-06-03T12:27:46 Z | jakobrs | A Plus B (IOI23_aplusb) | C++17 | 1 ms | 348 KB |
#include "aplusb.h" #include <queue> #include <set> #include <vector> std::vector<int> smallest_sums(int N, std::vector<int> A, std::vector<int> B) { auto cmp = [&](std::pair<int, int> a, std::pair<int, int> b) { auto [a1, a2] = a; auto [b1, b2] = b; return A[a1] + B[a2] > A[b1] + B[b2]; }; auto pq = std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, decltype(cmp)>(cmp); pq.push({0, 0}); auto seen = std::set<std::pair<int, int>>{}; std::vector<int> results; for (int i = 0; i < N; i++) { auto [a, b] = pq.top(); pq.pop(); if (seen.find({a, b}) != seen.end()) continue; seen.insert({a, b}); results.push_back(A[a] + B[b]); if (a + 1 < A.size()) pq.push({a + 1, b}); if (b + 1 < B.size()) pq.push({a, b + 1}); } return results; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | 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 | 1 ms | 344 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 | 1 ms | 344 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Incorrect | 1 ms | 348 KB | 1st lines differ - expected: 20 tokens, found 16 tokens |
8 | 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 | 1 ms | 344 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Incorrect | 1 ms | 348 KB | 1st lines differ - expected: 20 tokens, found 16 tokens |
8 | 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 | 1 ms | 344 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Incorrect | 1 ms | 348 KB | 1st lines differ - expected: 20 tokens, found 16 tokens |
8 | Halted | 0 ms | 0 KB | - |