내가 작성한 코드

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int N;
pair <int,int> xy[100000];
 
 
int main() {
 
    cin >> N;
 
    for (int i = 0; i < N; i++) {
        cin >> xy[i].first >> xy[i].second;
 
    }
 
    sort(xy, xy + N);
 
    for (int i = 0; i < N; i++) {
        // endl 시간 초과
        cout << xy[i].first << ' ' << xy[i].second << '\n';
    }
 
    return 0;
}
cs
  • 처음에는 직접 quick sort를 작성하여 채점해 보았으나 정답으로 처리가 되지 않았다.
  • 원인을 찾지 못하여 그냥 C++ 안의 내장 함수(algorithm - sort)를 이용하여 작성하니 정답으로 처리되었다.

코드 채점 결과

+ Recent posts