USACO/Bronze
백준 5939 Race Results (USACO November 2010 Bronze 2번)
ssam..
2020. 3. 24. 09:51
문제 링크: 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
|