-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
이번 문제는 특이하게 백준에서 실행시간이 좀더 걸렸다. 자바를 잘짠건가? 파이썬이 특이하게 작동한건가??? + GPT활용겸 자바를 변환 시켰는데 빠르고 완벽하다... GPT가 질투난다!!! ㅋㅋㅋ + 덕분에 파이썬에서 클래스를 쓰는법을 배워간다 ㅋ
- Loading branch information
1 parent
54979e0
commit f3dd19c
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |