Submission #1060710

# Submission time Handle Problem Language Result Execution time Memory
1060710 2024-08-15T21:04:51 Z SzymonKrzywda A Plus B (IOI23_aplusb) C++17
100 / 100
84 ms 14344 KB
#include <bits/stdc++.h>
using namespace std;


vector<int> smallest_sums(int n, vector<int> A, vector<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;
    
}

# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 348 KB Output is correct
5 Correct 1 ms 344 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 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 348 KB Output is correct
5 Correct 1 ms 344 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 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 440 KB Output is correct
24 Correct 1 ms 444 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 2 ms 740 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 2 ms 488 KB Output is correct
35 Correct 1 ms 604 KB Output is correct
36 Correct 2 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 348 KB Output is correct
5 Correct 1 ms 344 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 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 440 KB Output is correct
24 Correct 1 ms 444 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 2 ms 740 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 2 ms 488 KB Output is correct
35 Correct 1 ms 604 KB Output is correct
36 Correct 2 ms 600 KB Output is correct
37 Correct 13 ms 2908 KB Output is correct
38 Correct 61 ms 11148 KB Output is correct
39 Correct 51 ms 9228 KB Output is correct
40 Correct 54 ms 9208 KB Output is correct
41 Correct 64 ms 11148 KB Output is correct
42 Correct 58 ms 11020 KB Output is correct
43 Correct 83 ms 14344 KB Output is correct
44 Correct 11 ms 2840 KB Output is correct
45 Correct 51 ms 8188 KB Output is correct
46 Correct 49 ms 8336 KB Output is correct
47 Correct 50 ms 8336 KB Output is correct
48 Correct 84 ms 11276 KB Output is correct
49 Correct 66 ms 13324 KB Output is correct
50 Correct 81 ms 14344 KB Output is correct
51 Correct 69 ms 8276 KB Output is correct
52 Correct 70 ms 8276 KB Output is correct
53 Correct 70 ms 8264 KB Output is correct