1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#include <cstring> #include <cstdio> #include <cmath> #include <queue> #include <algorithm> #define rep(i,l,r) for(int i=l;i<=r;++i) #define per(i,l,r) for(int i=l;i>=r;--i) #define MAXN 100010 using namespace std; inline int () { char c; bool t=0; int a=0; while((c=getchar())==' '||c=='n'||c=='r'); if(c=='-') { t=1;c=getchar(); } while(c>='0'&&c<='9') { a*=10;a+=(c-'0');c=getchar(); } return a*(t?-1:1); } priority_queue<int> q; int a[MAXN],b[MAXN],ans[MAXN],n,cnt; int main() { n=read(); rep(i,1,n)a[i]=read(); rep(i,1,n)b[i]=read(); sort(a+1,a+n+1); sort(b+1,b+n+1); rep(i,1,n) q.push(a[1]+b[i]); rep(i,2,n) { rep(j,1,n) { if(a[i]+b[j]<q.top()) { q.pop(); q.push(a[i]+b[j]); } else break; } } while(!q.empty()) { ans[++cnt]=q.top(); q.pop(); } while(cnt) printf("%d ",ans[cnt--]); return 0; }
|
近期评论