1. What I learned
a. pair<>
This is a class that binds two objects together so that they can be treated as one object.
a. Vector vs Array
The array is faster than the vector, so use the array if possible.
2. Code
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(void) {
int num_of_points, x, y;
pair<int,int> points[100000];
scanf("%d", &num_of_points);
for (int i=0 ; i<num_of_points ; i++) {
scanf("%d %d", &x, &y);
points[i] = pair<int,int>(x,y);
}
sort(points, points+num_of_points);
for (int i=0 ; i<num_of_points ; i++) {
printf("%d %d\n", points[i].first, points[i].second);
}
return 0;
}
3. Result
Runtime : 60 ms, Memory usage : 1776 KB
(Runtime can be different by a system even if it is a same code.)