문제 바로가기
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
나의 코드 및 설명
t = int(input())
for test_case in range(1,t+1):
n,m,k = map(int, input().split())
customers = list(map(int, input().split()))
customers.sort()
max_time = max(customers)
total = 0
i = 0
ans = 1
for time in range(0, max_time+1):
if time != 0 and time % m == 0:
total += k
if time == customers[i]:
if total >= 1:
total -= 1
i+=1
else:
ans = -1
break
if ans == 1:
print("#{} {}".format(test_case, "Possible"))
else:
print("#{} {}".format(test_case, "Impossible"))
피드백
처음에는 while문을 이용해서 문제를 풀려다가 시간초과 에러로 인해 실패했다. for문으로 다시 풀어서 정답 판정을 받을 수 있었다.
'SWEA (SW Expert Academy) > D3' 카테고리의 다른 글
[SWEA/D3] 4615 재미있는 오셀로 게임 (1) | 2023.05.06 |
---|---|
[SWEA/D3] 13428 숫자 조작 / 백트래킹 (1) | 2023.05.03 |
[SWEA/D3] 1225 암호생성기 / DFS, for문 실행시간 비교 (0) | 2023.04.26 |
[SWEA/D3] 1220 Magnetic (0) | 2023.04.26 |
[SWEA/D3] 1244 최대 상금 / 백트래킹 (0) | 2023.04.26 |
문제 바로가기
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
나의 코드 및 설명
t = int(input())
for test_case in range(1,t+1):
n,m,k = map(int, input().split())
customers = list(map(int, input().split()))
customers.sort()
max_time = max(customers)
total = 0
i = 0
ans = 1
for time in range(0, max_time+1):
if time != 0 and time % m == 0:
total += k
if time == customers[i]:
if total >= 1:
total -= 1
i+=1
else:
ans = -1
break
if ans == 1:
print("#{} {}".format(test_case, "Possible"))
else:
print("#{} {}".format(test_case, "Impossible"))
피드백
처음에는 while문을 이용해서 문제를 풀려다가 시간초과 에러로 인해 실패했다. for문으로 다시 풀어서 정답 판정을 받을 수 있었다.
'SWEA (SW Expert Academy) > D3' 카테고리의 다른 글
[SWEA/D3] 4615 재미있는 오셀로 게임 (1) | 2023.05.06 |
---|---|
[SWEA/D3] 13428 숫자 조작 / 백트래킹 (1) | 2023.05.03 |
[SWEA/D3] 1225 암호생성기 / DFS, for문 실행시간 비교 (0) | 2023.04.26 |
[SWEA/D3] 1220 Magnetic (0) | 2023.04.26 |
[SWEA/D3] 1244 최대 상금 / 백트래킹 (0) | 2023.04.26 |