본문 바로가기

PyPy9

백준 1940 주몽 1 2 3 4 5 6 7 8 9 import sys n=int(input()) m=int(input()) ingredientList=list(map(int, sys.stdin.readline().split())) ans=0 for i in range(n): for j in range(i+1,n): if ingredientList[i]+ingredientList[j]==m: ans+=1 print(ans) Colored by Color Scripter cs 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 n=int(input()) m=int(input()) ingredientList=list(map(int, input().split())) ingredientList.sort() start,.. 2021. 12. 27.
백준 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.
[백준] 14659 1 2 3 4 5 6 7 8 9 10 n=int(input()) tmp=list(map(int, input().split())) cnt=0 for i in range(n): tmpcnt=0 for j in range(i+1,n): if tmp[i]>tmp[j] : tmpcnt+=1 else: break cnt=max(cnt,tmpcnt) print(cnt) cs pypy ㅠㅠ 2021. 1. 14.
[백준] 2399 1 2 3 4 5 6 7 8 import sys n=int(sys.stdin.readline()) tmp=list(map(int, sys.stdin.readline().split())) cnt=0 for i in range(n): for j in range(n): cnt+=abs(tmp[i]-tmp[j]) print(cnt) Colored by Color Scripter cs pypy3로 풀었구요 죄송합니당.ㅠㅜㅠ 조건 그 자체로 구현 하는건 쉽습니다 하지만 python3 로 돌리면 시간초과가 뜨기에 손으로 수학문제 풀듯이 풀면 쉽게 구할거같은데...ㅋㅋ 2021. 1. 7.
[백준] 1773 1 2 3 4 5 6 7 8 import sys n,c=map(int, sys.stdin.readline().split()) firework=[0]*(c+1) for _ in range(n): pok=int(sys.stdin.readline()) for i in range(c+1): if i%pok==0: firework[i]=1 print(sum(firework)-1) cs 시간초과나서 pypy 3로 돌렸습니다. 죄송합니다 시간줄여서 해볼게요 2021. 1. 6.
[백준] 1225 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import sys a,b = sys.stdin.readline().split() tmpA=[] tmpB=[] tmp=0 for i in range(len(a)): tmpA.append( int (a[i])) for i in range(len(b)): tmpB.append( int (b[i])) for i in range(len(tmpA)): for j in range(len(tmpB)): tmp+= tmpA[i]*tmpB[j] print(tmp) cs 우선 pypy3로 풀었구요 최대 경우의수가 9999*9999 이므로 약 1억이거든요 시간이나 메모리 관리에 신경써야 할 문제 입니다. 2021. 1. 5.
[백준] 17618 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import sys def singi(n): tmp=n cnt=0 while tmp!=0: cnt+=tmp%10 tmp=tmp//10 if n%cnt==0 : return 1 else : return 0 n=int(sys.stdin.readline()) ans=0 for i in range(1,n+1): if singi(i)==1: ans+=1 print (ans) cs 일단 이 문제도 저처럼 하시면 python3 로는 시간초과뜹니다. 구현 방식이 얼추 비슷한것같은데 고민이 좀 더 필요해보이네요 2021. 1. 5.
[백준] 16561 1 2 3 4 5 6 7 8 import sys n=int(sys.stdin.readline()) cnt=0 for i in range(1,n//3): for j in range(1, n // 3): for k in range(1, n // 3): if 3*i+3*j+3*k==n: cnt+=1 print(cnt) cs 3중 for문 .. 허허 interpreter를 python3로 하시면 시간초과뜹니다. pypy3로 하면 통과는 되는데 이렇게 하시면 안돼용 2021. 1. 5.
[백준] 1975 1 2 3 4 5 6 7 8 9 10 11 12 13 import sys t = int(sys.stdin.readline()) for i in range(t): n = int(sys.stdin.readline()) cnt = 0 for j in range(2, n+1): tmp = n while (tmp//j)!=0: if tmp%j==0: cnt+=1 tmp/=j else: break print(cnt) cs python3로 채점하면 시간초과나서 pypy3로 통과됐습니다. 죄송합니다 이런 식으로 짜면되는데 그대로 참조하시면 안됩니더 2020. 12. 17.