-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAR_464.cpp
70 lines (64 loc) · 1.19 KB
/
AR_464.cpp
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <iostream>
#include <string>
using namespace std;
typedef struct {
int tiempo;
int pose;
int poss;
} tCorredor;
int stringtoTiempo(string t);
int main() {
int casos, t = 0;
tCorredor l[100];
tCorredor tAux;
string time;
while (cin >> casos) {
for (int i = 0; i < casos; ++i) {
cin >> time;
tAux.pose = i;
tAux.tiempo = stringtoTiempo(time);
int j = 0;
while (tAux.tiempo > l[j].tiempo && i != 0 && j < i)
j++;
for (int k = i; k > j; --k)
l[k] = l[k - 1];
l[j] = tAux;
}
l[0].poss = 1;
for (int i = 0; i < casos - 1; ++i) {
if ((l[i + 1].tiempo - l[i].tiempo) <= 1)
l[i + 1].poss = l[i].poss;
else
l[i + 1].poss = i + 2;
}
bool encontrado;
for (int i = 0; i < casos; ++i) {
int j = 0;
encontrado = false;
while (!encontrado)
if (l[j].pose == i)
encontrado = true, cout << l[j].poss << "\n";
else
++j;
}
cout << "---\n";
}
return 0;
}
int stringtoTiempo(string t)
{
string aux = "";
int tiempo = 0;
aux += t[0];
aux += t[1];
tiempo += stoi(aux) * 3600;
aux = "";
aux += t[3];
aux += t[4];
tiempo += stoi(aux) * 60;
aux = "";
aux += t[6];
aux += t[7];
tiempo += stoi(aux);
return tiempo;
}