#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define vc vector
typedef vc<ll> vcll;
typedef vc<bool> vcb;
#define pr pair
typedef pr<ll, ll> prll;
typedef map<ll,ll> mapll;
typedef unordered_map<ll,ll> umapll;
#define f0r(i,a,n) for ((i)=(a); (i)<=(n); (i)++)
#define r0f(i,n,a) for ((i)=(n); (i)>=(a); (i)--)
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define fi first
#define se second
#define sz size
#define all(x) (x).begin(), (x).end()
#define all0(x, n) (x).begin(), (x).begin()+n
#define all1(x, n) (x).begin()+1, (x).begin()+n+1
#define allrev(x) (x).rbegin(), (x).rend()
#define in(v, s) ((s).find((v)) != (s).end())
#define GCD(x, y) __gcd(abs((x)), abs((y)))
#define INF (LLONG_MAX>>3ll)
#define MOD 1'000'000'007ll
#define mxN 100'010ll
inline void maxa(ll &a, ll b) { if (a<b) a=b; }
inline void mina(ll &a, ll b) { if (a>b) a=b; }
ll n;
vc<int> ans;
int *ar, *bar;
struct pnt { ll i, j; };
inline pnt mpnt (ll i, ll j)
{
pnt ans;
ans.i=i, ans.j=j;
return ans;
}
inline ll s (pnt a) { return ar[a.i] + bar[a.j]; }
inline bool operator< (const pnt &a, const pnt &b) { return s(a) > s(b); }
vc<int> smallest_sums(int N, vc<int> A, vc<int> B)
{
n=N;
sort(all0(A, n));
sort(all0(B, n));
ll i, j;
f0r(i,1,n) ar[i]=A[i-1], bar[i]=B[i-1];
ll cnt=0;
priority_queue<pnt> pq;
pq.push(mpnt(1,1));
f0r(cnt,1,n)
{
pnt ij = pq.top(); pq.pop();
ans.pb(s(ij));
i=ij.i, j=ij.j;
if (i!=n) pq.push(mpnt(i+1, j));
if (j!=n) pq.push(mpnt(i, j+1));
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |