[백준]/C++
백준 2751번 수 정렬하기 2 [C++]
경우42
2023. 8. 4. 20:35
반응형
문제 간단 정리
정렬문제 아마도 내장함수를 사용하지 않는다면 n logN의 시간복잡도를 갖는 정렬로 풀어야한다.
문제 해결 방법
sort 내장함수 사용 ><
전체 코드
#include<vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
vector<int> vec;
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int input;
cin >> input;
vec.push_back(input);
}
sort(vec.begin(), vec.end());
for (int a : vec) {
cout << a << "\n";
}
}
반응형