문제 링크: https://www.acmicpc.net/problem/5939
5939번: Race Results
The herd has run its first marathon! The N (1 <= N <= 5,000) times have been posted in the form of Hours (0 <= Hours <= 99), Minutes (0 <= Minutes <= 59), and Seconds (0 <= Seconds <= 59). Bessie must sort them (by Hours, Minutes, and Seconds) into ascend
www.acmicpc.net
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
|
#include <bits/stdc++.h>
using namespace std;
struct race {
int h, m, s;
};
int n;
race t[5001];
bool cmp(race a, race b) {
return a.h == b.h ? (a.m == b.m ? a.s < b.s : a.m < b.m) : a.h < b.h;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i = 0; i < n; i++)
cin >> t[i].h >> t[i].m >> t[i].s;
sort(t, t + n, cmp);
for(int i = 0; i < n; i++)
cout << t[i].h << ' ' << t[i].m << ' ' << t[i].s << '\n';
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
'USACO > Bronze' 카테고리의 다른 글
백준 5947 Book Club (USACO December 2010 Bronze 1번) (0) | 2020.04.06 |
---|---|
백준 5940 Math Practice (USACO November 2010 Bronze 3번) (0) | 2020.03.24 |
백준 5938 Daisy Chains in the Field (USACO November 2010 Bronze 1번) (0) | 2020.03.24 |
백준 18788 Swapity Swap (USACO February 2020 Bronze 3번) (0) | 2020.03.24 |
백준 18787 Mad Scientist (USACO February 2020 Bronze 2번) (0) | 2020.03.23 |