1 条题解
-
0Guest LV 0
-
0
#include <cstdio> #include<bits/stdc++.h> using namespace std; const int maxn=200010; int a[maxn],b[maxn]; priority_queue<int>q; int n; inline int read() { int x=0;char ch=0; while (!isdigit(ch)) ch=getchar(); while (isdigit(ch)) {x=x*10+ch-48;ch=getchar();} return x; } int main() { n=read(); for (int i=1;i<=n;++i)a[i]=read(); for (int i=1;i<=n;++i)b[i]=read(); sort(a+1,a+n+1);sort(b+1,b+n+1); for (int i=1;i<=n;++i) { for (int j=1;j<=n;++j) { if (i==1) {q.push(a[i]*b[j]);} else { if (q.top()<=a[i]*b[j]) break; else {q.pop(),q.push(a[i]*b[j]);} } } } for (int i=n;i>=1;--i) b[i]=q.top(),q.pop(); for (int i=1;i<=n;++i) printf("%d ",b[i]); }
- 1