Skip to content

Instantly share code, notes, and snippets.

@honux77
Created October 23, 2020 15:23
Show Gist options
  • Select an option

  • Save honux77/a72ae65c97559cd67172fd773ed3b35c to your computer and use it in GitHub Desktop.

Select an option

Save honux77/a72ae65c97559cd67172fd773ed3b35c to your computer and use it in GitHub Desktop.
BOJ 18870 TE answer
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
using ull = long long int;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
set<int> s(a.begin(), a.end());
for (auto &i: a) {
auto it = lower_bound(s.begin(), s.end(), i);
cout << distance(s.begin(), it) << " ";
}
cout << "\n";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment