Page 1 of 1

### 518 - Time

Posted: Sun Dec 30, 2001 1:34 pm
In problem 518 ("Time") you have a test input pair listed as:

1996 12 31 20 30 0
1997 1 1 7 30 0
60 minute

1996 12 31 20 30 0
1997 1 1 7 30 0
1 hour

In the above you will note that the D1 and D2 values are identical. Also
1 hour equals 60 minutes (3600 seconds). I would expect identical
answers in this case, but the output that you have listed has 11 and to
respectively. What's the reason?
Thank you very much.

<font size=-1>[ This Message was edited by: marceh on 2001-12-30 12:34 ]</font>

Posted: Sun Dec 30, 2001 8:29 pm
Time computed as a sum 'Time from first point to end of year' + 'Time from start of year to end point' in integers.
I.e. for minutes sum will be 210 + 450 = 660, 660 / 60 = 11; for hours it will be 3.5 + 7.5, the fractional parts are not counts, so 3 + 7 = 10.

Posted: Thu Mar 28, 2002 11:14 am
can i have some tricky test cases? coz i get WA in it.

### 518 Incorrect example?

Posted: Sat Feb 26, 2005 9:24 pm
The last 2 cases of the sample input are:

1996 12 31 20 30 0
1997 1 1 7 30 0
60 minute

1996 12 31 20 30 0
1997 1 1 7 30 0
1 hour

I think 60 minutes ARE 1 hour so why the sample output in these 2 cases is:

11
10

Posted: Sat Feb 26, 2005 11:16 pm
Hour periods start (and end) at hour boundaries, i.e. x hours, 0 minutes, 0 seconds.
Also year periods start at January 1, 0 hours, 0 minutes, 0 seconds. Month periods start at the 1st of the month, 0 hours, 0 minutes, 0 seconds, etc.
So in the given example, the first 60 minute period starts at 1996 12 31 20 30 0 (a minute boundary), but the first 1 hour period starts at 1996 12 31 21 0 0 (an hour boundary).

### 518 Time. Give Output for this input please.

Posted: Sat Dec 03, 2005 10:40 pm
Hi all!
I try to solve this problem, but get WA and cannot understand why. Please, give me output for this input.
2028 11 8 0 15 16
2028 11 27 2 26 27
16 hour

2003 12 11 10 44 44
2025 12 17 15 10 58
17 minute

1991 9 20 14 39 31
1991 11 20 22 44 46
21 day

1987 2 20 0 4 22
1998 9 6 3 39 41
32 second

1995 7 6 9 8 46
2017 7 11 17 25 41
16 day

2008 1 19 11 38 29
2009 10 2 4 38 7
35 year

2025 11 18 22 3 33
2029 11 27 0 55 24
39 second

2011 9 4 13 43 40
2016 10 14 13 45 31
55 second

1971 11 13 23 50 27
1975 8 10 12 2 31
41 day

1989 10 13 11 29 7
2017 10 24 21 47 46
29 year

1996 1 11 18 21 37
2008 3 20 6 56 3
28 month

1996 12 14 4 8 1
2028 12 22 8 6 22
20 minute

2028 2 19 3 32 47
2029 8 21 23 6 42
38 year

2016 8 13 14 12 12
2020 12 13 19 57 40
18 month

1974 3 9 22 5 0
1989 7 22 2 53 2
27 minute

1982 11 17 12 43 46
2026 11 28 15 26 26
34 minute

1974 10 6 1 59 13
2014 1 23 4 29 49
55 second

1998 11 23 20 3 56
2004 12 7 12 17 55
25 minute

1979 11 20 7 45 0
2009 12 5 4 1 7
4 day

1993 3 7 23 20 8
2023 11 18 2 25 2
45 month

1987 9 5 11 56 57
1987 11 5 15 51 0
18 year

2008 6 17 1 56 38
2015 7 27 6 3 3
54 second

1979 8 5 23 8 30
2027 9 15 7 4 55
28 hour

1978 2 27 17 53 12
2001 9 1 15 29 17
2 year

1988 2 1 14 16 13
2028 11 17 12 34 32
3 second

1977 1 2 9 33 15
1978 12 13 4 47 41
53 month

1976 9 28 4 28 41
2010 12 10 19 49 10
4 hour

2004 8 16 22 15 37
2011 9 24 23 28 58
5 month

2026 6 8 10 46 19
2026 10 24 13 57 13
21 year

2022 8 28 4 28 21
2029 10 28 22 15 0
27 year

1979 8 6 0 12 56
1988 8 28 7 52 9
41 second

2008 2 27 23 42 27
2011 8 9 15 32 5
48 second

2013 10 7 16 52 29
2014 11 18 11 1 46
37 year

2010 3 16 12 46 41
2026 8 1 22 30 53
6 day

2000 5 25 22 34 44
2029 10 27 14 23 29
4 second

1972 4 18 8 0 18
2020 9 11 12 17 41
16 minute

2028 10 14 5 29 2
2029 12 19 3 33 20
31 year

1990 7 1 23 0 58
1998 1 19 10 29 38
4 minute

2009 12 2 11 40 7
2020 11 11 18 2 35
18 day

1984 6 25 0 49 55
2003 10 25 13 28 8
39 year

1991 5 1 8 29 33
1993 12 9 23 52 28
3 month

1976 12 18 0 31 54
1980 1 24 19 47 13
17 hour

1996 8 26 20 37 55
2026 1 17 13 51 4
32 minute

1976 4 20 23 6 8
2005 12 18 21 56 29
0 second

2016 4 24 7 14 6
2027 5 24 2 2 54
2 hour

1975 3 17 19 42 42
1983 12 7 22 19 38
57 day

1974 4 26 21 40 12
1991 9 22 13 35 37
14 second

2007 4 14 19 47 26
2014 6 18 2 18 3
30 second

1994 9 2 22 10 13
2004 4 9 14 55 10
14 hour

1978 12 28 19 54 32
2021 3 28 14 59 51
4 year

1995 2 22 23 1 15
1998 4 16 5 32 3
40 year

1977 12 15 22 40 38
2006 12 21 6 46 36
37 second

2013 11 28 15 48 21
2020 12 28 20 57 35
57 second

1994 6 26 10 37 50
2028 3 8 7 55 28
32 month

1980 6 14 20 7 58
2018 4 22 1 36 9
40 hour

1995 5 3 10 24 37
1995 4 9 5 27 48
28 hour

1999 7 13 8 2 36
2014 6 20 6 41 49
8 day

2005 8 8 0 4 35
2024 12 23 13 43 55
12 month

1998 10 1 1 26 42
2028 1 27 21 16 41
58 year

2011 10 26 11 52 34
2020 10 13 5 52 20
5 minute

1978 9 16 12 51 8
2007 6 28 19 47 14
52 year

2028 7 6 8 18 38
2028 7 9 20 32 34
47 year

1999 2 4 19 1 52
2006 8 25 1 4 32
40 minute

2003 12 24 9 16 31
2022 2 1 10 47 27
27 minute

2003 3 17 9 28 27
2014 9 18 1 51 25
44 year

1984 9 23 6 3 50
2015 6 11 13 11 54
28 second

2016 4 1 15 51 54
2020 10 5 22 59 38
56 day

2017 6 20 23 49 26
2020 6 11 21 57 58
47 month

1979 6 6 16 4 13
2013 10 5 11 8 10
2 minute

1978 11 6 14 12 41
2019 4 18 20 40 26
28 year

1983 6 17 9 15 23
1999 3 15 13 10 20
1 month

2025 11 16 7 17 12
2025 11 27 19 21 35
42 minute

2002 8 22 10 28 29
2012 11 22 23 35 0
1 day

2010 1 13 21 52 46
2021 3 16 9 20 22
25 minute

1972 2 2 9 40 1
1992 5 18 21 41 47
54 second

1979 2 6 21 53 31
2005 7 6 5 0 11
35 hour

2019 3 12 13 37 26
2019 3 15 12 13 47
53 day

1983 11 19 2 54 3
2017 10 21 6 15 50
46 minute

1975 1 25 17 54 31
1997 5 13 23 53 27
32 minute

2029 10 1 3 6 45
2029 12 5 16 40 0
2 minute

1995 6 19 19 45 35
2011 9 14 17 15 54
59 year

2002 5 25 3 48 5
2010 12 9 6 25 53
57 month

2004 4 25 14 40 40
2008 10 14 13 13 38
36 year

2007 12 23 8 18 13
2017 12 18 8 55 35
17 month

2011 6 24 15 24 9
2027 8 4 23 44 45
23 day

1971 9 2 10 25 26
1979 4 2 9 5 40
57 second

1999 11 23 8 11 53
2022 12 28 16 13 26
0 hour

1992 8 18 10 42 49
2009 12 19 13 42 40
6 year

2024 5 23 18 6 7
2029 11 1 11 1 45
49 hour

1987 12 4 21 48 33
2014 12 14 5 8 56
23 day

2008 1 4 20 37 46
2013 11 5 6 16 32
51 hour

2014 11 15 23 40 27
2024 12 18 16 33 30
23 second

2002 5 12 19 18 17
2023 8 28 10 28 9
35 month

2028 3 11 4 43 48
2028 9 9 4 13 2
2 day

2000 3 13 9 9 43
2002 9 19 10 27 38
9 hour

2009 9 10 5 10 52
2011 9 26 18 10 30
44 hour

1980 9 18 0 21 9
1990 7 5 9 35 35
24 minute

1976 1 3 18 27 45
1996 8 26 11 47 26
57 year

2003 3 7 18 8 23
2007 8 19 22 58 18
31 day

1982 9 14 15 4 44
1990 8 10 13 0 25
54 minute

1976 3 11 21 27 6
2018 10 3 11 7 57
17 month

2026 5 13 7 41 56
2026 6 16 15 15 42
47 hour

1978 5 9 1 25 10
1995 6 20 13 50 48
47 year

1983 2 18 23 1 18
1997 4 26 13 4 14
15 minute

1992 1 13 21 24 15
2029 6 26 9 12 18
49 month

1973 5 10 5 2 43
1973 6 16 7 50 28
4 second

1991 2 16 16 4 31
2025 3 7 6 58 12
43 month

2016 3 22 22 10 35
2022 1 18 15 39 56
28 minute

2011 10 21 9 30 16
2015 6 19 3 23 0
1 minute

2013 9 16 20 38 2
2024 9 27 1 43 56
36 day

2019 5 14 6 48 32
2023 2 5 12 3 50
48 hour

1982 2 1 15 49 49
2010 7 4 23 24 51
39 second

1997 11 23 9 46 11
1998 10 23 16 20 45
43 hour

1970 12 6 7 43 12
1985 6 13 11 26 7
59 month

1973 1 19 18 37 55
2006 10 3 22 45 11
42 day

1997 5 25 22 6 34
1998 11 25 23 33 9
7 second

2010 9 22 19 46 9
2010 9 28 20 59 30
32 year

1992 11 5 18 24 33
2009 11 15 16 19 31
10 hour

1994 12 20 14 31 2
2021 11 10 18 23 26
5 hour

1982 10 3 2 8 45
1984 7 25 17 8 41
3 hour

1971 7 6 0 16 32
1984 4 18 3 0 34
30 year

1993 8 1 10 2 25
1995 8 1 22 55 31
26 day

1982 5 26 19 59 26
1984 9 19 23 20 23
28 year

2024 8 1 21 39 10
2027 8 5 16 47 30
45 day

2021 10 14 0 55 54
2023 10 5 3 1 30
20 minute

1979 11 9 8 43 54
2017 12 19 5 13 31
58 hour

1984 3 21 17 55 59
2017 10 26 8 17 38
31 hour

2023 5 11 8 19 49
2023 5 7 7 1 48
4 month

1998 4 26 5 51 42
2024 7 28 9 49 8
18 hour

2020 1 28 14 18 46
2026 5 21 1 17 3
33 minute

2027 12 27 14 48 41
2029 12 26 3 26 21
13 month

1992 11 8 22 44 59
2018 8 24 23 27 6
15 hour

2000 5 7 23 58 24
2007 11 27 3 42 54
18 hour

2023 10 17 9 41 36
2029 11 20 12 34 51
38 minute

1974 2 5 5 52 5
2013 11 19 7 33 36
26 day

1989 5 18 3 36 26
2006 8 16 21 20 15
34 day

2025 10 13 2 8 30
2029 12 15 5 15 41
9 minute

1984 3 6 4 2 25
2010 5 14 21 8 54
18 minute

2013 4 22 12 45 29
2029 5 19 1 17 24
51 minute

2017 3 8 15 39 30
2023 5 11 22 31 33
10 hour

2026 10 27 20 52 55
2028 1 18 15 2 5
2 month

1971 1 14 13 35 28
2003 3 9 11 6 47
27 month

1993 1 14 20 2 5
2011 6 27 9 25 12
31 second

1994 8 20 14 42 9
2014 10 28 21 49 0
15 hour

2015 7 8 5 40 20
2023 11 22 2 25 43
57 year

2009 4 13 7 27 36
2020 4 26 8 46 34
21 day

2022 5 28 11 55 1
2024 6 27 6 49 33
56 month

1997 12 16 16 27 29
2019 10 28 12 48 6
4 month

2001 6 11 15 7 3
2002 10 14 21 52 18
41 year

2023 10 24 3 14 13
2027 3 3 6 36 36
43 month

2019 12 20 10 18 33
2028 12 23 1 56 32
23 minute

2019 1 19 21 2 34
2028 8 28 1 55 23
41 minute

2010 4 11 12 3 37
2025 6 21 14 34 13
25 day

2028 1 15 5 52 25
2029 7 11 15 3 8
24 second

2012 7 21 3 45 14
2012 12 17 14 5 40
38 second

1989 2 16 16 38 57
1990 9 3 7 57 32
2 month

1995 9 14 13 8 7
2029 9 9 17 53 12
21 year

1970 7 12 2 23 19
1993 11 8 10 4 35
37 minute

1991 12 20 8 13 18
2009 10 18 1 0 35
59 day

1997 12 1 10 3 47
2018 3 5 16 16 26
22 day

1984 2 2 0 4 57
2018 2 7 2 28 42
13 year

2015 1 10 3 45 45
2016 7 16 5 27 2
31 minute

2006 12 6 11 21 23
2018 12 12 3 46 41
3 month

1970 7 21 12 47 49
2026 8 25 4 51 19
48 minute

1974 6 17 12 58 29
2007 4 27 15 52 24
19 second

1996 3 10 5 24 45
2009 8 21 10 21 27
20 day

1979 6 22 19 43 36
2025 10 18 18 25 58
32 second

2027 11 9 2 27 58
2027 11 18 4 46 59
50 year

1986 11 28 13 58 14
2011 12 28 15 59 57
20 hour

1983 6 16 21 16 26
2013 11 23 9 6 49
52 day

1976 2 22 22 51 46
2008 8 4 1 25 22
19 second

2001 4 1 11 44 21
2017 12 22 14 19 8
49 day

1991 11 14 22 14 28
2026 11 1 13 24 17
50 minute

1989 6 4 2 21 1
1992 1 2 1 19 55
27 minute

2026 10 12 5 2 39
2026 10 21 0 53 16
45 hour

Posted: Thu Dec 28, 2006 1:35 am
Below is my accepted solution's output. NOTE that your input contains invalid test cases such as "0 second" so I simply output 0 for those. Finally, here are my thoughts on the problem. The problem looks annoying, but it's easier if you use some tricks. For me, I actually solved it by separating the calculations for second/minute/hour/day from month/year. Another thing to watch out is you need to understand why the last 2 sample input return different results. There's another thread on this problem that sorta explains that.

28
681220
2
11383603
502
0
3254664
2932889
33
0
5
842123
0
2
299370
681124
22548993
127046
2743
8
0
4153873
15061
11
429117966
0
74949
16
0
0
6975891
2265587
0
996
232127831
1591036
0
993052
222
0
10
1599
483107
0
48561
55
39235866
7549261
6011
10
0
24746215
3921672
12
8295
-20
681
19
0
943127
0
0
99297
352750
0
34616460
29
0
9028651
1
188
394
3744
234977
11858401
6614
0
387865
366491
47206
0
1
0
7
255
4197137
0
2
973
429
1003
13845425
7
90
2453
407
214643
0
52
76984
30
17
0
497336
9
801716
9
109426
1924912
111
681
22996392
186
2
293
6776970
0
14925
47146
5292
0
28
0
24
51918
5759
9500
0
12786
100558
1
15072
3678
84358
558
185
243860
765256
165755
5412
7
14
18778225
11798
0
191
0
65
0
0
206023
123214
221
1956176
339758
9
1
331601
110
336
2
25691
47
614660
54578065
245
45683854
0
10993
213
53891348
124
367794
50237
4