practivceAlgorithm 570

[백준][Python] 2578 빙고

call될때마다 0으로 바꾸는 방식 5개 0이면 빙고 1줄 import sys input = sys.stdin.readline def check(x,y): global cnt if not row_check[x] and not sum(bingo[x]): row_check[x] = True cnt += 1 if not col_check[y]: for i in range(5): if bingo[i][y]: break else: col_check[y] = True cnt += 1 if x==y and not diagonal_check[0]: for i in range(5): if bingo[i][i]: break else: diagonal_check[0] = True cnt += 1 if x+y==4 and n..

[백준][Python] 2559 수열

정답이 음수값인 케이스를 고려못해서 한참 고생함.. max값 초기화는 늘 음의 무한대로 할것.. 0으로 햇다가 낭패봄 import sys input = sys.stdin.readline N, K = map(int, input().split()) arr = list(map(int, input().split())) left = 0 sum_arr = 0 max_sum = -float('inf') for right in range(N): sum_arr += arr[right] if right-left+1 == K: max_sum = max(max_sum,sum_arr) sum_arr -= arr[left] left += 1 print(max_sum)

[백준][Python] 2628 종이자르기

가로 세로 길이 집합 구해서 곱한 것들중에 최댓값 import sys input = sys.stdin.readline N, M = map(int, input().split()) cut_row = [0,M] cut_col = [0,N] for _ in range(int(input())): a,b = map(int,input().split()) if not a: cut_row.append(b) else: cut_col.append(b) cut_row.sort() cut_col.sort() len_row = [] len_col = [] for i in range(1,len(cut_row)): len_row.append(cut_row[i] - cut_row[i-1]) for i in range(1,len(cut..

[백준][Python] 1244 스위치 켜고 끄기

XOR연산 import sys input = sys.stdin.readline N = int(input()) switches = list(map(int, input().split())) M = int(input()) for _ in range(M): a, b = map(int, input().split()) # 남학생이면 스위치 번호가 받은 수의 배수이면 그 스위치의 상태를 바꾼다. XOR(3을 받으면 3,6끔) # 여학생은 자기가 받은 스위치 번호를 중심으로 좌우가 대칭이면서 가장 많은 스위치를 포함하는 구간을 찾아 상태를 모두 바꾼다. XOR if a==1: for i in range(N): if not (i+1)%b: switches[i] ^= 1 else: size=1 while b-1-size>..