Skip to content

Commit

Permalink
✨feat: [BOJ] 1946_신입사원- 파이썬 구현
Browse files Browse the repository at this point in the history
이번 문제는 특이하게 백준에서 실행시간이 좀더 걸렸다. 자바를 잘짠건가? 파이썬이 특이하게 작동한건가???
+ GPT활용겸 자바를 변환 시켰는데 빠르고 완벽하다... GPT가 질투난다!!! ㅋㅋㅋ
+ 덕분에 파이썬에서 클래스를 쓰는법을 배워간다 ㅋ
  • Loading branch information
JeonHyoChang committed Mar 4, 2023
1 parent 54979e0 commit f3dd19c
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
28 changes: 28 additions & 0 deletions JeonHyoChang/Week_02/Python/BOJ_1946_신입사원.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import sys

T = int(sys.stdin.readline())
result = list()

for _ in range(T):
grade_list = list()
N = int(sys.stdin.readline())
for _ in range(N):
fg, sg = map(int, sys.stdin.readline().split())
grade_list.append((fg, sg))

grade_list.sort(key=lambda o: o[0])

# 합격자 수 & 기준이 되는 2차 성적
passer_count = 1
standard = grade_list[0][1]

# 기준보다 등수가 높을시 합격자에 추가하며, 기준을 그사람으로 변경
for i in range(1, N):
if standard > grade_list[i][1]:
passer_count += 1
standard = grade_list[i][1]

result.append(passer_count)

for temp in result:
print(temp)
38 changes: 38 additions & 0 deletions JeonHyoChang/Week_02/Python/BOJ_1946_신입사원_GPT.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import sys
from typing import List

class Grade:
def __init__(self, fg: int, sg: int):
self.fg = fg
self.sg = sg

def main() -> None:
T = int(sys.stdin.readline())
result: List[int] = []
for i in range(T):
grade_list: List[Grade] = []
N = int(sys.stdin.readline())
for j in range(N):
fg, sg = map(int, sys.stdin.readline().split())
grade_list.append(Grade(fg, sg))

# sort the list by first grade in ascending order
grade_list.sort(key=lambda x: x.fg)

# count the number of passing applicants & set the standard of the second grade
passer_count = 1
standard = grade_list[0].sg

# if the rank is higher than the standard, add the applicant to the passer list and change the standard
for x in range(1, N):
if standard > grade_list[x].sg:
passer_count += 1
standard = grade_list[x].sg

result.append(passer_count)

for temp in result:
print(temp)

if __name__ == '__main__':
main()

0 comments on commit f3dd19c

Please sign in to comment.