Submission #971841

#TimeUsernameProblemLanguageResultExecution timeMemory
971841phoebeA Plus B (IOI23_aplusb)C++17
100 / 100
91 ms10248 KiB
#include "aplusb.h"
#include <bits/stdc++.h>
using namespace std;

#define pii pair<int, int>

vector<int> smallest_sums(int n, vector<int> a, vector<int> b){
    priority_queue<pair<int, pii>> pq;
    set<pii> seen;
    vector<int> re;
    pq.push({-(a[0] + b[0]), {0, 0}});
    while (re.size() < n){
        int i = pq.top().second.first, j = pq.top().second.second; pq.pop();
        if (seen.count({i, j})) continue;
        seen.insert({i, j});
        re.push_back(a[i] + b[j]);
        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 re;
}

Compilation message (stderr)

aplusb.cpp: In function 'std::vector<int> smallest_sums(int, std::vector<int>, std::vector<int>)':
aplusb.cpp:12:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   12 |     while (re.size() < n){
      |            ~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...