fragment-header
fragment-markdown
홈
로그인
로그아웃
내 블로그
설정
로그인
백준 33654 (C++) Sort of Sort
최초 업로드: 2025-04-17 00:23:08
최근 수정 시간: 2025-07-25 09:48:37
게시자: rlatjwls3333
카테고리: 백준
조회수: 9
# [Bronze II] Sort of Sort [문제 링크](https://www.acmicpc.net/problem/33654) ## 문제 설명 <p>Sorting takes so long... but if we don’t mind losing some data we can sort of sort much faster!</p> <p>A sort of sorted list is a monotonically increasing list containing all elements of another list $a$ that were originally in sorted order. That is, a sort of sorted list obtained from list $a$ contains all $a_i$ such that $a_i≥a_j$ for all $0≤j<i$.</p> ## 입력 <p>The first line of input contains a single integer $N$, the length of the unsorted list ($1≤N≤100,000$). The next line contains $N$ space separated integers $a_i$ ($-200,000≤a_i≤200,000$).</p> ## 출력 <p>Output a single line of space separated integers representing the sort of sorted list obtained from the given list $a$.</p> ## 풀이 #### 입력받은 N개의 수를 오름차순이 되도록 삭제한 후 출력하면 된다. ``` c++ #include<bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int last=-200000; while(n--) { int cur; cin >> cur; if(last<=cur) { cout << cur << ' '; last = cur; } } } ```