[Python] 백준 #20365- 블로그 2
·
코딩테스트/백준[Python]
문제 20365번: 블로그2 neighbor 블로그를 운영하는 일우는 매일 아침 풀고 싶은 문제를 미리 정해놓고 글을 올린다. 그리고 매일 밤 각각의 문제에 대하여, 해결한 경우 파란색, 해결하지 못한 경우 빨간색으로 칠한 www.acmicpc.net 코드 My answer import sys input=sys.stdin.readline n=int(input()) a=input() cnt=0 temp=[a[0]] for i in range(1,len(a)): if(a[i]!=temp[-1] and a[i]!='\n'): temp.append(a[i]) temp='.'.join(temp) b=temp.count('B') r=temp.count('R') c=temp.count('.')+1 answer=min..
[Python] 백준 #1541- 잃어버린 괄호
·
코딩테스트/백준[Python]
문제 1541번: 잃어버린 괄호 첫째 줄에 식이 주어진다. 식은 ‘0’~‘9’, ‘+’, 그리고 ‘-’만으로 이루어져 있고, 가장 처음과 마지막 문자는 숫자이다. 그리고 연속해서 두 개 이상의 연산자가 나타나지 않고, 5자리보다 www.acmicpc.net 코드 My answer import sys input=sys.stdin.readline a=input() n_temp=[] c_temp=['/n'] temp='' for i in range(len(a)): if(a[i]!='+' and a[i]!='-' and i!=len(a)-1): temp+=a[i] else: if(c_temp[-1]=='+'): n_temp[-1]+=int(temp) else: n_temp.append(int(temp)) tem..
[Python] 백준 #2217- 로프
·
코딩테스트/백준[Python]
문제 2217번: 로프 N(1 ≤ N ≤ 100,000)개의 로프가 있다. 이 로프를 이용하여 이런 저런 물체를 들어올릴 수 있다. 각각의 로프는 그 굵기나 길이가 다르기 때문에 들 수 있는 물체의 중량이 서로 다를 수도 있다. 하 www.acmicpc.net 코드 My answer import sys input = sys.stdin.readline rope=[] n=int(input()) for i in range(n): rope.append(int(input())) rope.sort(reverse=True) answer=[(i[0]+1)*i[1] for i in enumerate(rope)] print(max(answer)) Another answer n=int(input()) maximum=sort..
[Python] 백준 #2828 - 사과 담기 게임
·
코딩테스트/백준[Python]
문제 2828번: 사과 담기 게임 상근이는 오락실에서 바구니를 옮기는 오래된 게임을 한다. 스크린은 N칸으로 나누어져 있다. 스크린의 아래쪽에는 M칸을 차지하는 바구니가 있다. (M=start and a
[Python] 백준 #13305- 주유소
·
코딩테스트/백준[Python]
문제 13305번: 주유소 표준 입력으로 다음 정보가 주어진다. 첫 번째 줄에는 도시의 개수를 나타내는 정수 N(2 ≤ N ≤ 100,000)이 주어진다. 다음 줄에는 인접한 두 도시를 연결하는 도로의 길이가 제일 왼쪽 도로부터 N-1 www.acmicpc.net 코드 My answer import sys input=sys.stdin.readline n=int(input()) k=list(map(int,input().split())) cost=list(map(int,input().split())) result=0 start=cost[0] starti=0 for i in range(1,len(cost)): if(cost[i]
[Python/백준] 기초문제들 2
·
코딩테스트/백준[Python]
[A+B-2]-2558번 2558번: A+B - 2 첫째 줄에 A, 둘째 줄에 B가 주어진다. (0 < A, B < 10) www.acmicpc.net My answer a,b=int(input()),int(input()) print(a+b) Another answer print(sum(map(int,open(0)))) [A+B-3]-10950번 10950번: A+B - 3 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. www.acmicpc.net My answer for _ in range(int(input())): print(sum(map(int,input().split()))) [A+B-4]-10951번 10951번: A+B - 4 두 정수 A와 B를 입력받은 다음, ..