# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
905895 | Unforgettablepl | A Plus B (IOI23_aplusb) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
/*
ID: samikgo1
TASK:
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef complex<ll> point;
#define X real()
#define Y imag()
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
//#define f first
//#define s second
//#define x first
//#define y second
const ll INF = INT32_MAX;
const ll sqrtn = 440;
const ll modulo = 998244353;
const ll siz = 2e6;
const ll hashp = 923981238;
const ll hashm = 932439994;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//#define int ll
std::vector<int> smallest_sums(int N, std::vector<int> A, std::vector<int> B) {
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>> q;
vector<int> ans(N);
vector<int> curr(N,0);
for(int i=0;i<N;i++)q.emplace(A[i]+B[0],i);
for(int i=0;i<N;i++){
auto top = q.top();q.pop();
ans[i] = top.first;
q.emplace(A[top.second]+B[++curr[top.second]],top.second);
}
return ans;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
// freopen("cses.fi.txt","r",stdin);
// freopen(".out","w",stdout);
// int t;
// cin >> t;
// while (t--)
int n;
cin >> n;
vector<int> a(n),b(n);
for(int&i:a)cin>>i;
for(int&i:b)cin>>i;
for(int&i:smallest_sums(n,a,b))cout<<i<<' ';
}