코딩테스트/백준[Python]

백준 파이썬 코딩테스트 문제 풀이
[빗물]-14719번 14719번: 빗물 첫 번째 줄에는 2차원 세계의 세로 길이 H과 2차원 세계의 가로 길이 W가 주어진다. (1 ≤ H, W ≤ 500) 두 번째 줄에는 블록이 쌓인 높이를 의미하는 0이상 H이하의 정수가 2차원 세계의 맨 왼쪽 위치 www.acmicpc.net My answer row,column=map(int,input().split()) tmp=list(map(int,input().split())) res,index=0,0 start=tmp[0] for i in range(len(tmp)-1): if(tmp[i+1]>=start or (i+1==len(tmp)-1 and tmp[i+1]!=0)): #기둥이 정해진지점보다 같아지거나 높아질 때 혹은 마지막이면서 마지막기둥이 0이 ..
[연산자 끼워넣기]-14888번 14888번: 연산자 끼워넣기 첫째 줄에 수의 개수 N(2 ≤ N ≤ 11)가 주어진다. 둘째 줄에는 A1, A2, ..., AN이 주어진다. (1 ≤ Ai ≤ 100) 셋째 줄에는 합이 N-1인 4개의 정수가 주어지는데, 차례대로 덧셈(+)의 개수, 뺄셈(-)의 개수, www.acmicpc.net My answer from itertools import permutations min,max=1000000000,-1000000000 n=int(input()) #입력할 숫자의 개수 nums=list(map(int,input().split())) #계산할 숫자들 tmp=list(map(int,input().split())) #연산자들의 개수 op='+'*tmp[0]+'-'*t..
[쉽게 푸는 문제]-1292번 검색 www.acmicpc.net My answer a,b=input().split() a=int(a) b=int(b) tmp=[] sum=0 for i in range(b): if(len(tmp)>b): break while(tmp.count(i+1)!=i+1): if(len(tmp)>b): break tmp.append(i+1) for i in range(a-1,b): sum+=tmp[i] print(sum) Another answer p=[] for i in range(1,46): p+=[i]*i a,b=map(int,input().split()) print(sum(p[a-1:b])) 더보기 어제부터 계속 나오는데 input받을 때 map 쓰는 걸 익숙해져야겠다. 우선..
[약수구하기]-2501번 2501번: 약수 구하기 첫째 줄에 N과 K가 빈칸을 사이에 두고 주어진다. N은 1 이상 10,000 이하이다. K는 1 이상 N 이하이다. www.acmicpc.net My answer divisor=[] N,k=input().split() N=int(N) k=int(k) for i in range(1,N+1): if(N%i==0): divisor.append(i) if(len(divisor)
창빵맨
'코딩테스트/백준[Python]' 카테고리의 글 목록 (27 Page)