| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1060708 | SzymonKrzywda | A Plus B (IOI23_aplusb) | C++17 | 0 ms | 0 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
vector<int> smallest_sums(int n, int A[], int B[]){
    
    priority_queue<pair<int,pair<int,int>>> kolejka;
    set<pair<int,int>> secik;
    
    vector<int> wynik(n);
    
    kolejka.push({-(A[0]+B[0]),{0,0}});
    
    for (int i=0; i<n; i++){
        wynik[i] = -kolejka.top().first;
        
        int y = kolejka.top().second.first;
        int x = kolejka.top().second.second;
        kolejka.pop();
        
        if (y+1<n && secik.find({y+1,x})==secik.end()){
            kolejka.push({-(A[y+1]+B[x]),{y+1,x}});
            secik.insert({y+1,x});
        } 
        if (x+1<n && secik.find({y,x+1})==secik.end()){
            kolejka.push({-(A[y]+B[x+1]),{y,x+1}});
            secik.insert({y,x+1});
        } 
    
    }
    
    return wynik;
    
}
