Submission #963410

#TimeUsernameProblemLanguageResultExecution timeMemory
963410rxlfd314A Plus B (IOI23_aplusb)C++17
10 / 100
1 ms348 KiB
#include "aplusb.h" #include <bits/stdc++.h> using namespace std; using ari2 = array<int, 2>; using ari3 = array<int, 3>; #define vt vector #define size(x) (int((x).size())) #define all(x) begin(x), end(x) #define REP(a,b,c,d) for(int a=(b);(d)>0?a<=(c):a>=(c);a+=(d)) #define FOR(a,b,c) REP(a,b,c,1) #define ROF(a,b,c) REP(a,b,c,-1) vt<int> smallest_sums(int N, vt<int> A, vt<int> B) { map<ari2, bool> seen; priority_queue<ari3, vt<ari3>, greater<ari3>> pq; pq.push({A[0]+B[0], 0, 0}); vt<int> ans; seen[{0, 0}] = true; while (size(pq)) { auto [s, i, j] = pq.top(); pq.pop(); if (size(ans) == N) break; ans.push_back(s); if (i+1 < N && !seen[{i+1, j}]) pq.push({A[i+1]+B[j], i+1, j}); if (j+1 < N && !seen[{i, j+1}]) pq.push({A[i]+B[j+1], i, j+1}); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...