From 7d753becf4a01b4b73841f5d57632337c1ab8af3 Mon Sep 17 00:00:00 2001 From: hadongun Date: Wed, 7 May 2025 22:14:44 +0900 Subject: [PATCH] 2025-05-07 --- hadongun/README.md | 4 +- .../\355\206\265\352\263\204\355\225\231.py" | 80 +++++++++++++++++++ 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 "hadongun/\354\210\230\355\225\231/\355\206\265\352\263\204\355\225\231.py" diff --git a/hadongun/README.md b/hadongun/README.md index b367d92..95ae3aa 100644 --- a/hadongun/README.md +++ b/hadongun/README.md @@ -9,6 +9,8 @@ | 5차시 | 2025.04.02 | 스택 | [스택2](https://www.acmicpc.net/problem/28278)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/20| | 6차시 | 2025.04.04 | 정렬 | [단어 정렬](https://www.acmicpc.net/problem/1181)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/21| | 7차시 | 2025.04.07 | 스택 | [균형 잡힌 세상](https://www.acmicpc.net/problem/4949)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/25| - | 8차시 | 2025.04.09 | 그리디 알고리즘즘 | [알바생 강호](https://www.acmicpc.net/problem/1758)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/29| + | 8차시 | 2025.04.09 | 그리디 알고리즘 | [알바생 강호](https://www.acmicpc.net/problem/1758)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/29| + | 9차시 | 2025.05.02 | 스택 | [제로](https://www.acmicpc.net/problem/10773)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/36| + | 10차시| 2025.05.07 | 수학 | [통계학](https://www.acmicpc.net/problem/2108)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/36| --- \ No newline at end of file diff --git "a/hadongun/\354\210\230\355\225\231/\355\206\265\352\263\204\355\225\231.py" "b/hadongun/\354\210\230\355\225\231/\355\206\265\352\263\204\355\225\231.py" new file mode 100644 index 0000000..7518ca1 --- /dev/null +++ "b/hadongun/\354\210\230\355\225\231/\355\206\265\352\263\204\355\225\231.py" @@ -0,0 +1,80 @@ +import sys +N = int(input()) +su = [] +for _ in range(N): + su.append(int(sys.stdin.readline())) +su.sort() +length = len(su) + +#산술평균 +average = 0 +for i in range(length): + average += su[i] +print(average//length) + +#중앙값 +print(su[(length//2)]) +#최빈값 +count = [0]*8001 +for ch in su: + count[ch + 4000] += 1 +Max = count[0] +temp = 0 +max_list = [] +Max = max(count) +for k in range(len(count)): + if count == Max: + max_list.append(k-4000) +if len(max_list) > 1: + print(max_list[1]) +else: + print(max_list[0]) + +print(temp-4000) + +#범위 +print(su[length-1] - su[0]) + +"""" +#최빈값 실패 +yang = [0]*500001 +emm = [0]*500001 +for i in range(length): + if su[i] >= 0: + yang[su[i]] += 1 + else: + emm[abs(su[i])] += 1 +Max = 0 +count = 0 +dex = 0 + +for j in range(500001): + if Max < yang[j]: + Max = yang[j] + dex = j + elif Max < emm[j]: + Max = emm[j] + dex = -j + elif Max == emm[j]: + count += 1 + if count == 2: + dex = -j + Max = emm[j] + + elif Max == yang[j]: + count += 1 + if count == 2: + dex = j + Max = yang[j] + +print(dex) +"""" + + + + + + + + +