본문 바로가기

python-algorithm1422

[백준] 14593 1 2 3 4 5 6 7 8 9 10 11 12 cnta=0 cntb=999 cntc=999 ans=0 for i in range(int (input())): a,b,c=map(int,input().split()) if cntab: cnta=a; cntb=b;cntc=c;ans=i+1 if cntb==b: if cntc>c: cnta=a; cntb=b;cntc=c;ans=i+1 print(ans) Colored by Color Scripter cs 2021. 1. 14.
[백준] 14581 1 2 3 4 s=input() print(":fan::fan::fan:") print(":fan::%s::fan:"%s) print(":fan::fan::fan:") cs 이게 왜 브론즈 2인지 잘 이해가 안가네요 쉬운 문제입니다. 2021. 1. 14.
[백준] 14487 1 2 3 n=int(input()) tmp=list(map(int,input().split())) print(sum(tmp)-max(tmp)) cs 어짜피 한바퀴 돌아야되는데 이동거리가 가장 큰 지역부터 돌면 최소가 되니까 입력을 list 로 받아서 전체 합에서 가장 큰 거 하나만 빼주면 됩니더 2021. 1. 14.
[백준] 14471 1 2 3 4 5 6 7 8 9 10 n,m=map(int,input().split()) cnt=0 least=[] for _ in range (m): ai,bi=map(int, input().split()) if ai>=n: cnt+=1 else: least.append( (n-ai)); least=sorted(least) if cnt >= m-1: print(0) else: print(sum(least[:m-cnt-1])) cs 2021. 1. 14.
[백준] 14219 1 2 3 4 5 6 a,b=map(int,input().split()) cnt=0 if a%3!=0 : cnt+=1 if b%3!=0 : cnt+=1 if cnt==2:print("NO") else: print("YES") cs 2021. 1. 14.
[백준] 13458 1 2 3 4 5 6 7 8 9 10 import math cnt=0 n=int(input()) ai=list(map(int, input().split())) b,c=map(int, input().split()) for i in range(n): cnt+=1 if ai[i]-b>0 : cnt+=math.ceil((ai[i]-b)/c) print(cnt) cs 2021. 1. 14.
[백준] 13420 1 2 3 4 for _ in range(int(input())): a,b=input().split('=') if eval(a)== int(b) :print('correct') else: print('wrong answer') cs python 내장함수 eval 쓰시면 쉽게 풀 수 있습니다 ㅎㅎ 2021. 1. 14.
[백준] 13419 1 2 3 4 5 6 7 8 9 10 11 12 13 14 for _ in range(int(input())): s=input() if len(s)%2==1: for i in range(0,len(s),2): print(s[i],end='') for i in range(1, len(s),2): print(s[i], end='') print() for i in range(1, len(s), 2): print(s[i], end='') for i in range(0,len(s),2): print(s[i],end='') print() else: for i in range(0, len(s), 2): print(s[i], end='') print() for i in range(1, len(s), 2): print(.. 2021. 1. 14.
[백준] 13410 1 2 3 4 5 6 import math a,b=map(int, input().split()) tmp=[] for i in range(1,b+1): tmp.append(int (str(a*i)[::-1])) print(max(tmp)) cs 2021. 1. 14.
[백준] 13304 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 import math n,k=map(int, input().split()) bg12=0 b34=0 g34=0 b56=0 g56=0 for _ in range(n): s,y=map(int,input().split()) if y==1 or y==2: bg12+=1 elif s==0: if y==3 or y==4 : g34+=1 elif y==5 or y==6 : g56+=1 elif s==1: if y==3 or y==4 : b34+=1 elif y==5 or y==6 : b56+=1 print(math.ceil(bg12/k)+math.ceil(b34/k)+math.ceil(b56/k)+math.ceil(g34/k)+math.c.. 2021. 1. 14.
[백준] 13300 1 2 3 4 5 6 7 8 9 10 11 12 import math n,k=map(int, input().split()) boys=[0]*6 girls=[0]*6 for _ in range(n): s,y=map(int,input().split()) if s==0: girls[y-1]+=1 else:boys[y-1]+=1 cnt=0 for i in range(6): cnt+=int (math.ceil( boys[i]/k)) +int (math.ceil( girls[i]/k)) print(cnt) Colored by Color Scripter cs 2021. 1. 14.
[백준] 13163 1 2 3 4 5 6 for _ in range(int(input())): s=list(input().split()) print('god',end='') for i in range(1,len(s)): print(s[i],end='') print() cs 2021. 1. 14.