Post

๐ŸฆŠ ์•„๋‚ ๋กœ๊ทธ ์‹œ๊ณ„

1. ๋ฌธ์ œ ๋งํฌ

PCCP 3๋ฒˆ: ์•„๋‚ ๋กœ๊ทธ ์‹œ๊ณ„


2. ์ฝ”๋“œ

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def solution(h1, m1, s1, h2, m2, s2):
    # ๋ถ„์นจ๊ณผ ์ดˆ์นจ์€ ์ •์‹œ๋ฅผ ์ œ์™ธํ•˜๊ณ  1๋ถ„์— 1๋ฒˆ์”ฉ ๋งŒ๋‚œ๋‹ค
    setha_minutes = [((3600 * i) / (60 - 1)) for i in range(86400)]
    # ์‹œ์นจ๊ณผ ์ดˆ์นจ์€ 12์‹œ ์ค‘๋ณต์„ ์ œ์™ธํ•˜๊ณ  1๋ถ„์— 1๋ฒˆ์”ฉ ๋งŒ๋‚œ๋‹ค
    setha_hours = [((3600 * i) / (60 - 1/12)) for i in range(86400)]

    begin = h1 * 3600 + m1 * 60 + s1
    end = h2 * 3600 + m2 * 60 + s2
    meet = []

    for i in range(86400):
        if begin <= setha_hours[i] <= end and setha_hours[i] not in meet:
            meet.append(setha_hours[i])
        if begin <= setha_minutes[i] <= end and setha_minutes[i] not in meet:
            meet.append(setha_minutes[i])
    return len(meet)
  • ํ…Œ์ŠคํŠธ ๊ฒฐ๊ณผ
    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
    
    ์ฑ„์ ์„ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.
    ์ •ํ™•์„ฑ  ํ…Œ์ŠคํŠธ
    ํ…Œ์ŠคํŠธ 1 ใ€‰	ํ†ต๊ณผ (54.86ms, 16.9MB)
    ํ…Œ์ŠคํŠธ 2 ใ€‰	ํ†ต๊ณผ (46.64ms, 16.8MB)
    ํ…Œ์ŠคํŠธ 3 ใ€‰	ํ†ต๊ณผ (47.21ms, 16.8MB)
    ํ…Œ์ŠคํŠธ 4 ใ€‰	ํ†ต๊ณผ (41.42ms, 16.7MB)
    ํ…Œ์ŠคํŠธ 5 ใ€‰	ํ†ต๊ณผ (69.59ms, 16.7MB)
    ํ…Œ์ŠคํŠธ 6 ใ€‰	ํ†ต๊ณผ (35.87ms, 16.8MB)
    ํ…Œ์ŠคํŠธ 7 ใ€‰	ํ†ต๊ณผ (46.98ms, 16.7MB)
    ํ…Œ์ŠคํŠธ 8 ใ€‰	ํ†ต๊ณผ (44.41ms, 16.7MB)
    ํ…Œ์ŠคํŠธ 9 ใ€‰	ํ†ต๊ณผ (53.15ms, 16.8MB)
    ํ…Œ์ŠคํŠธ 10 ใ€‰	ํ†ต๊ณผ (53.21ms, 16.9MB)
    ํ…Œ์ŠคํŠธ 11 ใ€‰	ํ†ต๊ณผ (39.14ms, 16.8MB)
    ํ…Œ์ŠคํŠธ 12 ใ€‰	ํ†ต๊ณผ (35.08ms, 16.7MB)
    ํ…Œ์ŠคํŠธ 13 ใ€‰	ํ†ต๊ณผ (76.28ms, 16.8MB)
    ํ…Œ์ŠคํŠธ 14 ใ€‰	ํ†ต๊ณผ (59.90ms, 16.7MB)
    ํ…Œ์ŠคํŠธ 15 ใ€‰	ํ†ต๊ณผ (45.67ms, 16.9MB)
    ํ…Œ์ŠคํŠธ 16 ใ€‰	ํ†ต๊ณผ (57.40ms, 16.7MB)
    ํ…Œ์ŠคํŠธ 17 ใ€‰	ํ†ต๊ณผ (40.80ms, 16.7MB)
    ํ…Œ์ŠคํŠธ 18 ใ€‰	ํ†ต๊ณผ (38.97ms, 16.7MB)
    ํ…Œ์ŠคํŠธ 19 ใ€‰	ํ†ต๊ณผ (80.01ms, 16.8MB)
    ํ…Œ์ŠคํŠธ 20 ใ€‰	ํ†ต๊ณผ (84.69ms, 16.7MB)
    ์ฑ„์  ๊ฒฐ๊ณผ
    ์ •ํ™•์„ฑ: 100.0
    ํ•ฉ๊ณ„: 100.0 / 100.0
    


3. ํ•ด์„ค

๋ถ„์นจ๊ณผ ์ดˆ์นจ์€ ์ •์‹œ๋ฅผ ์ œ์™ธํ•˜๊ณ  1๋ถ„์— 1๋ฒˆ์”ฉ ๋งŒ๋‚œ๋‹ค

์‹œ์นจ๊ณผ ์ดˆ์นจ์€ 12์‹œ ์ค‘๋ณต์„ ์ œ์™ธํ•˜๊ณ  1๋ถ„์— 1๋ฒˆ์”ฉ ๋งŒ๋‚œ๋‹ค

์‹œ์ž‘ ์‹œ๊ฐ๊ณผ ์ข…๋ฃŒ ์‹œ๊ฐ์„ ์ดˆ๋กœ ๋‚˜ํƒ€๋‚ด์–ด ๋ชจ๋“  ๊ฒน์น˜๋Š” ํšŸ์ˆ˜๋ฅผ ๊ตฌํ•œ๋‹ค

This post is licensed under CC BY 4.0 by the author.