정화 코딩

Good Bye, BOJ 2023! 본문

Contest

Good Bye, BOJ 2023!

jungh150c 2024. 1. 9. 22:57

https://www.acmicpc.net/contest/view/1221

 


 

A. 2023은 무엇이 특별할까? (백준 31090번)

 

https://www.acmicpc.net/problem/31090

 

#python

from sys import stdin

t = int(stdin.readline())
for i in range(t):
    n = int(stdin.readline())
    div = n % 100
    if (n + 1) % div == 0:
        print("Good")
    else:
        print("Bye")

 

(정답)

 


 

B. 거짓말 (백준 31091번)

 

https://www.acmicpc.net/problem/31091

 

#python

from sys import stdin

n = int(stdin.readline())
data = list(map(int, stdin.readline().split()))
lie = []
notLie = []
ans = []

for x in data:
    if x > 0:
        lie.append(x)
    else:
        notLie.append(-x)

lie.sort()
notLie.sort(reverse=True)

for i in range(n+1):
    lier = 0
    for j in range(len(lie)):
        if lie[j] > i:
            lier += len(lie) - j
            break
    for j in range(len(notLie)):
        if notLie[j] < i:
            lier += len(notLie) - j
            break
    if lier == i:
        ans.append(i)
    # for x in data:
    #     if x > 0:
    #         if x > i:
    #             lier += 1
    #     else:
    #         if -x < i:
    #             lier += 1
    #     if lier > i:
    #         break
    # if lier == i:
    #     ans.append(i)

print(len(ans))
for x in ans:
    print(x, end=" ")

 

하나하나 체크하는 방법밖에 생각이 안 났다... 당연히 시간 초과가 나서 틀림. (오답)

 

Comments