'전체 글'에 해당되는 글 84건

  1. 2020.05.21 :: [BOJ/11651] 좌표 정렬하기 2
  2. 2020.05.19 :: [BOJ/11650] 좌표 정렬하기
  3. 2020.05.18 :: [BOJ/2751] 수 정렬하기 2
Algorithm/Problem Solving 2020. 5. 21. 23:01

(공감과 댓글 하나는 글쓴이에게 큰 힘이 됩니다.)

 

문제 링크

- https://www.acmicpc.net/problem/11651

 

사용 알고리즘

- 정렬

 

풀이

 

소스 코드

- https://github.com/moomini/algorithm/blob/master/boj/11651.cpp

#include <cstdio>
#include <vector>
#include <algorithm>
 
using namespace std;
 
bool cmp(const pair<intint> &u, const pair<intint> &v) {
    if (u.second < v.second) return true;
    else if (u.second == v.second) return u.first < v.first;
    else return false;
}
 
int main(void) {
    int n; scanf("%d"&n);
    vector<pair<intint>> v(n);
    for (int i = 0; i < n; ++i) scanf("%d %d"&v[i].first, &v[i].second);
    sort(v.begin(), v.end(), cmp);
    for (int i = 0; i < n; ++i) printf("%d %d\n", v[i].first, v[i].second);
    return 0;
}
cs

'Algorithm > Problem Solving' 카테고리의 다른 글

[BOJ/10825] 국영수  (0) 2020.05.24
[BOJ/10814] 나이순 정렬  (0) 2020.05.22
[BOJ/11650] 좌표 정렬하기  (0) 2020.05.19
[BOJ/2751] 수 정렬하기 2  (0) 2020.05.18
[BOJ/2004] 조합 0의 개수  (0) 2020.05.17
posted by DevMoomin
:
Algorithm/Problem Solving 2020. 5. 19. 20:27

(공감과 댓글 하나는 글쓴이에게 큰 힘이 됩니다.)

 

문제 링크

- https://www.acmicpc.net/problem/11650

 

사용 알고리즘

- 정렬

 

풀이

 

소스 코드

- https://github.com/moomini/algorithm/blob/master/boj/11650.cpp

#include <cstdio>
#include <vector>
#include <algorithm>
 
using namespace std;
 
vector<pair<intint>> v;
 
int main(void) {
    int n; scanf("%d"&n);
    for (int i = 0; i < n; ++i) {
        pair<intint> p;
        scanf("%d %d"&p.first, &p.second);
        v.push_back(p);
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < n; ++i) printf("%d %d\n", v[i].first, v[i].second);
    return 0;
}
cs

'Algorithm > Problem Solving' 카테고리의 다른 글

[BOJ/10814] 나이순 정렬  (0) 2020.05.22
[BOJ/11651] 좌표 정렬하기 2  (0) 2020.05.21
[BOJ/2751] 수 정렬하기 2  (0) 2020.05.18
[BOJ/2004] 조합 0의 개수  (0) 2020.05.17
[BOJ/1676] 팩토리얼 0의 개수  (0) 2020.05.17
posted by DevMoomin
:
Algorithm/Problem Solving 2020. 5. 18. 21:48

(공감과 댓글 하나는 글쓴이에게 큰 힘이 됩니다.)

 

문제 링크

- https://www.acmicpc.net/problem/2751

 

사용 알고리즘

- 정렬

 

풀이

 

소스 코드

- https://github.com/moomini/algorithm/blob/master/boj/2751.cpp

#include <cstdio>
#include <algorithm>
 
using namespace std;
 
int arr[1000003];
 
int main(void) {
    int n; scanf("%d"&n);
    for (int i = 0; i < n; ++i) scanf("%d"&arr[i]);
    sort(arr, arr + n);
    for (int i = 0; i < n; ++i) printf("%d\n", arr[i]);
    return 0;
}
cs

'Algorithm > Problem Solving' 카테고리의 다른 글

[BOJ/11651] 좌표 정렬하기 2  (0) 2020.05.21
[BOJ/11650] 좌표 정렬하기  (0) 2020.05.19
[BOJ/2004] 조합 0의 개수  (0) 2020.05.17
[BOJ/1676] 팩토리얼 0의 개수  (0) 2020.05.17
[BOJ/10872] 팩토리얼  (0) 2020.05.16
posted by DevMoomin
: