다시 도전하는 문제
1. 구간 합 구하기 5
https://www.acmicpc.net/problem/11660
나는 이렇게 풀었는,
n, m = map(int, input().split())
array = [list(map(int, input().split())) for _ in range(n)]
sum = [ [0 for _ in range(n+1)] for _ in range(n+1)]
result = []
for i in range(n) :
for j in range(n) :
sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + array[i][j]
for _ in range(m) :
x1, y1, x2, y2 = map(int,input().split())
answer = (sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 -1][y1 -1] )
result.append(answer)
print(result)
계속 틀렸다고 나옴 ;
2. 모의고사
https://school.programmers.co.kr/learn/courses/30/lessons/42840
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
def solution(answers):
# 각 수포자의 패턴
a = [1, 2, 3, 4, 5]
b = [2, 1, 2, 3, 2, 4, 2, 5]
c = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]
# 각 수포자의 점수 초기화
scores = [0, 0, 0]
# 정답 비교
for i in range(len(answers)):
if a[i % len(a)] == answers[i]:
scores[0] += 1
if b[i % len(b)] == answers[i]:
scores[1] += 1
if c[i % len(c)] == answers[i]:
scores[2] += 1
# 최고 점수와 해당 점수의 번호 반환
max_score = max(scores)
max_indices = [i + 1 for i, score in enumerate(scores) if score == max_score]
print(f"Scores: {scores}") # 각 수포자의 점수를 출력
print(f"Max Score: {max_score}, Winners: {max_indices}") # 최고 점수와 동점자 출력
return max_indices
3. 완주하지 못한 선수
https://school.programmers.co.kr/learn/courses/30/lessons/42576
from collections import Counter
def solution(participant, completion):
participant_counter = Counter(participant)
completion_counter = Counter(completion)
for person, count in participant_counter.items() :
if count != completion_counter[person] :
return person
'코딩테스트' 카테고리의 다른 글
하루 코테 3개 풀기 - 15일차 (0) | 2024.12.24 |
---|---|
하루 코테 3개 풀기 - 14일차 (0) | 2024.12.23 |
하루 코테 3개 풀기 - 12일 차 (0) | 2024.12.20 |
하루 코테 3개 풀기 - 11일 차 (0) | 2024.12.19 |
하루 코테 3개 풀기 - 10일 차 (0) | 2024.12.19 |