Advertisement
limimage

NAGOVNOKODILEBATB

May 30th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define endl "\n"
  3. using namespace std;
  4. using ll = long long;
  5. using pii = pair<int, int>;
  6.  
  7.  
  8. constexpr int N = 1e1+5,
  9. INF = 1e9+9;
  10.  
  11. double arr[N], ans[N];
  12. multimap<double, int> mp;
  13.  
  14. void Solve()
  15. {
  16. for (int i = 0; i < N; i++)
  17. {
  18. arr[i] = rand()%(int)1e3+(rand()%(int)1e3)/1e3;
  19. cout << arr[i] << " ";
  20. }
  21. cout << endl;
  22. mp.insert({arr[0],0});
  23. for (int i = 1; i < N; i++)
  24. {
  25. auto it = mp.lower_bound(arr[i]/2);
  26. if (it == mp.end())
  27. it =--mp.end();
  28. while(true)
  29. {
  30. if (it==mp.end())
  31. break;
  32. if (it->first*2<=arr[i])
  33. {
  34. ans[it->second] = i;
  35. auto iter = it;
  36. if (it==mp.begin())
  37. {
  38. mp.erase(iter);
  39. break;
  40. }
  41. it--;
  42. mp.erase(iter);
  43. }
  44. else if (it==mp.begin())
  45. break;
  46. else it--;
  47. }
  48. mp.insert({arr[i], i});
  49. }
  50. for (int i = 0; i < N; i++)
  51. {
  52. if (ans[i])
  53. cout << ans[i] << " ";
  54. else cout << "None ";
  55. }
  56. }
  57.  
  58. int main()
  59. {
  60. //freopen("peacefulsets.in", "r", stdin);
  61. //freopen("peacefulsets.out", "w", stdout);
  62. ios_base::sync_with_stdio(false);
  63. cin.tie(nullptr);
  64. cout.tie(nullptr);
  65. Solve();
  66. return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement