사생활 보호 설정
https://gamjia.tistory.com
Updated News
Mini Rooms
답글수 [0]
What Friends Say
한마디로 표현해봐~
1촌평 관리
11870번 좌표 압축
GamJia 2023. 4. 3. 09:14
단계별로 풀어보기 - 정렬 - 10단계
https://www.acmicpc.net/problem/18870
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int N,temp; cin>>N; vector<int>a,b; for(int i=0;i<N;i++) { cin>>temp; a.push_back(temp); b.push_back(temp); } sort(a.begin(),a.end()); a.erase(unique(a.begin(),a.end()),a.end()); for(int i:b) { int print=lower_bound(a.begin(),a.end(),i)-a.begin(); cout<<print<<" "; } return 0; }
🔊lower_bound()함수는
찾으려는 key 값이나 그보다 큰 숫자의
배열의 최초 위치를 알려준다