Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define endl "\n"
- using namespace std;
- using ll = long long;
- using pii = pair<int, int>;
- constexpr int N = 1e1+5,
- INF = 1e9+9;
- double arr[N], ans[N];
- multimap<double, int> mp;
- void Solve()
- {
- for (int i = 0; i < N; i++)
- {
- arr[i] = rand()%(int)1e3+(rand()%(int)1e3)/1e3;
- cout << arr[i] << " ";
- }
- cout << endl;
- mp.insert({arr[0],0});
- for (int i = 1; i < N; i++)
- {
- auto it = mp.lower_bound(arr[i]/2);
- if (it == mp.end())
- it =--mp.end();
- while(true)
- {
- if (it==mp.end())
- break;
- if (it->first*2<=arr[i])
- {
- ans[it->second] = i;
- auto iter = it;
- if (it==mp.begin())
- {
- mp.erase(iter);
- break;
- }
- it--;
- mp.erase(iter);
- }
- else if (it==mp.begin())
- break;
- else it--;
- }
- mp.insert({arr[i], i});
- }
- for (int i = 0; i < N; i++)
- {
- if (ans[i])
- cout << ans[i] << " ";
- else cout << "None ";
- }
- }
- int main()
- {
- //freopen("peacefulsets.in", "r", stdin);
- //freopen("peacefulsets.out", "w", stdout);
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- Solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement