본문 바로가기

백준1064

백준 10825 국영수 1 2 3 4 5 6 7 8 9 10 11 n=int(input()) ans=[] for i in range(n): name,kor,eng,mathScore=input().split() kor=int(kor) eng = int(eng) mathScore = int(mathScore) ans.append([name,kor,eng,mathScore]) ans=sorted(ans, key=lambda x: (-x[1],x[2],-x[3],x[0]) ) for i in range(n): print(ans[i][0]) Colored by Color Scripter cs 2021. 12. 21.
백준 11656 접미사 배열 1 2 3 4 5 6 7 s=input() lengthS=len(s) ans=[] for i in range(lengthS): ans.append(s[i:]) for i in sorted(ans): print (i) cs 2021. 12. 21.
백준 1543 문서 검색 1 2 3 4 s=input() target=input() cnt=len(s) print(s.count(target)) cs python count는 중복 제거해서 알아서 카운팅해주네요 2021. 12. 21.
백준 3276 ICONS 1 2 3 4 5 6 7 a=1 b=1 n=int(input()) while a*bb: b+=1 else : a+=1 print(a,b) cs 이런 문제는 전형적인 브루트포스 문제죵 2021. 12. 21.
백준 9625 BABBA 1 2 3 4 5 tmp=[[1,0],[0,1]] for i in range(2,46): tmp.append([ tmp[i-1][1] ,tmp[i-1][1]+tmp[i-1][0] ] ) n=int(input()) print(*tmp[n]) Colored by Color Scripter cs 처음 접근한 방식은 단순히 문제대로 문자열을 replace() 함수를 사용해서 변환하고 A,B 숫자를 세려했더니 시간초과가 나와서 A,B 개수의 점화식을 구하는 방식으로 구현했습니다. 점화식은 피타고라스 할아버지가 와도 눈으로 보고 바로 떠오르기 어렵기 때문에 손으로 반복문을 따라가면서 값을 적어나가보면 점화식 구할수있습니당 2021. 12. 21.
백준 11536 줄 세우기 1 2 3 4 5 6 7 8 9 n=int(input()) tmp=[] for i in range(n): tmp.append(input()) tmpD=sorted(tmp,reverse=True) tmpI=sorted(tmp) if tmp== tmpD :print("DECREASING") elif tmp ==tmpI:print("INCREASING") else: print("NEITHER") cs 2021. 12. 16.
백준 14729 칠무해 1 2 3 4 5 6 7 8 9 10 11 n=int(input()) tmp=[float(input()) for i in range(7)] tmp.sort() for i in range(n-7): cnt=float(input()) if tmp[6]>cnt: tmp.pop() tmp.append(cnt) tmp.sort() for i in tmp: print("%.3f"%(i)) cs 2021. 12. 14.
백준 11637 인기 투표 1 2 3 4 5 6 7 8 9 10 11 12 13 n=int(input()) for i in range(n): k=int(input()) tmp=[ int(input()) for j in range(k)] maxCnt=tmp.count(max(tmp)) mymax=max(tmp) majorFlag= max(tmp) >sum(tmp)/2 if majorFlag==1 : ismajor='majority' else : ismajor='minority' if maxCnt!=1: print("no winner") else : print("%s winner %d"%(ismajor,tmp.index(mymax)+1)) cs 2021. 12. 14.
백준 2435 기상청 인턴 신현수 1 2 3 4 5 6 7 import sys n,k=map(int ,input().split()) tmp=list(map(int,sys.stdin.readline().split())) mymax=-1*999999 for i in range(len(tmp)-k+1): mymax=max(mymax,sum(tmp[i:i+k])) print(mymax) Colored by Color Scripter cs 2021. 12. 14.
백준 15688 수 정렬하기 5 1 2 3 4 5 6 7 import sys n=int(sys.stdin.readline()) tmp=[] for i in range(n): tmp.append(int(sys.stdin.readline())) for i in sorted(tmp): print(i) cs 2021. 12. 14.
백준 4796 캠핑 1 2 3 4 5 6 7 8 cnt=1 while 1: l,p,v=map(int,input().split()) if l==0 and p==0 and v==0 : break else: ans= (v//p)*l + min(v%p,l) print("Case %d: %d"%(cnt,ans)) cnt+=1 cs 2021. 12. 14.
백준 14467 소가 길을 건너간 이유 1 1 2 3 4 5 6 7 8 9 10 11 12 13 ans=[[] for i in range(10)] n=int(input()) cnt=0 for i in range(n): idx,gil=map(int,input().split()) idx-=1 ans[idx].append(gil) for i in range(10): if len(ans[i])>1: for j in range(len(ans[i])-1): if ans[i][j]!=ans[i][j+1] : cnt+=1 else :pass print(cnt) Colored by Color Scripter cs 2021. 12. 14.