이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
// #define int long long
// #define Int __int128_t
// #define dbg(x) cout<<"["<< #x <<"] : "<<(x)<<endl;
// #define bpc(x) (__builtin_popcountll(x))
int bpow(int a, int b, long long mod=LLONG_MAX){
int res=1;while(b){if(b%2)res=res*a%mod;a=a*a%mod;b/=2;}return res;
}
int inv(int a, int mod=1e9+7){ return bpow(a, mod-2, mod); }
vector<int> smallest_sums(int n, vector<int>a, vector<int>b){
priority_queue<pair<int, pair<int,int>>> pq;
for(int i = 0; i < n; i++){
pq.push({-(a[i] + b[0]) ,{i, 0}});
}
// for(int i : a) dbg(i);
// for(int i : b) dbg(i);
vector<int> res;
while((int)res.size() < n){
int now = -pq.top().first;
auto[now_i, now_j] = pq.top().second;
res.push_back(now);
pq.pop();
pq.push({ -(a[now_i] + b[now_j+1]), {now_i, now_j + 1} });
}
return res;
}
// signed main(){
// vector<int> tmp =smallest_sums(2, {0, 2}, {1, 4});
// vector<int> tmp = smallest_sums(3, {0, 2, 2}, {3, 5, 6});
// for(int i : tmp){
// cout << i << ' ';
// }
// cout << '\n';
// }
/*
*/
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |