fork download
  1. // SIGMA BOY hihihihihihihi
  2.  
  3. #define se second
  4. #define fi first
  5. #define pb push_back
  6. #define pob pop_back
  7. #define bitebi __builtin_popcountll
  8. #include <bits/stdc++.h>
  9.  
  10. using namespace std ;
  11. typedef long long ll;
  12. typedef long double ld;
  13. typedef pair<ll,ll> pll;
  14. typedef pair<int,int> pii;
  15. const ll Mod = 1e9+7;
  16. const ll Maxn = 1e6+69;
  17. const ll Maxm = 1e3;
  18. const ll oo = 1e18;
  19. const int inf = 1e9;
  20.  
  21. int n;
  22. pll l[Maxn],d[Maxn];
  23. vector<pll> res ;
  24.  
  25. bool CheckSqinCir ( ll l , ll d )
  26. {
  27. return 2*l*l<=d*d;
  28. }
  29.  
  30. bool Check ( int k )
  31. {
  32. for (int i = 1 ; i <= k ; ++i) if(!CheckSqinCir(l[i].fi,d[n-k+i].fi)) return false;
  33. return true;
  34. }
  35.  
  36. void Print ( int k )
  37. {
  38. for (int i = 1 ; i <= k ; ++i) res.pb({l[i].se,d[n-k+i].se});
  39. for (int i = k+1; i <= n ; ++i) res.pb({l[i].se,d[i-k].se});
  40. sort(res.begin(),res.end());
  41. for (auto x: res)
  42. cout << x.se << ' ' ;
  43. }
  44.  
  45. void Do()
  46. {
  47. cin >> n ;
  48. for (int i = 1 ; i <= n ; ++i)
  49. {
  50. cin >> l[i].fi;
  51. l[i].se = i ;
  52. }
  53. for (int i = 1 ; i <= n ; ++i)
  54. {
  55. cin >> d[i].fi;
  56. d[i].se = i;
  57. }
  58. sort(l+1,l+1+n);
  59. sort(d+1,d+1+n);
  60. int L = 0 , R = n ;
  61. while(L<=R)
  62. {
  63. int mid = (L+R)/2;
  64. if(Check(mid)) L = mid+1;
  65. else R = mid-1;
  66. }
  67. Print(R);
  68. }
  69.  
  70. signed main ()
  71. {
  72. ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  73. #define task "test"
  74. if(fopen(task".inp", "r")){
  75. freopen(task".inp", "r", stdin);
  76. freopen(task".out", "w", stdout);
  77. }
  78. int ntest=1;
  79. while(ntest--) Do();
  80. cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms\n";
  81. }
  82.  
  83.  
Success #stdin #stdout #stderr 0.01s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Time elapsed: 5ms