슈뢰딩거의 고등어
[boj] 2751 수 정렬하기 2 본문
https://www.acmicpc.net/problem/2751
퀵 소트로 풀었지만 시간초과가 났다.
배열이 아닌 벡터로 입력을 받은후 algorithm : sort 를 사용해도 시간초과가 났다.
해결방법은 아래 방법
배열로 입력을 받고 소트 함수 사용
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int n;
scanf("%d", &n);
int *no;
no = new int [n];
for(int i=0; i<n; i++)
scanf("%d", &no[i]);
sort(no, no+n);
for(int i=0; i<n; i++)
printf("%d\n", no[i]);
}
'알고리즘' 카테고리의 다른 글
[백준] 1107 리모컨 (0) | 2022.03.20 |
---|---|
[백준] 1018 체스판 다시 칠하기 (0) | 2022.03.19 |
[프로그래머스] 쿼드압축 후 개수 세기 (0) | 2022.03.19 |
[프로그래머스] 이진 변환 반복하기 (0) | 2022.03.17 |
[프로그래머스] 짝지어 제거하기 (0) | 2022.03.16 |
Comments