import sys input=sys.stdin.readline n = int(input()) data = list(map(int,input().split())) data.sort() result = 0 # 총 그룹의 수 count = 0 #현재 그룹에 포함된 모험가의 수 for i in data: count += 1 if count >= i: result += 1 count = 0 print(result)
#N을 K로 나누거나 N에 -1을 할 때 #N이 1이 될 때까지의 COUNT를 구하여 출력한다 import sys input=sys.stdin.readline n,k = map(int,input().split()) cnt = 0 while True: if n == 1: break if n%k == 0: cnt+=1 n //= k else: cnt+=1 n -= 1 print(cnt)
수 찾기 문제는 아래와 같은 방법으로 값을 배열에 받아 in 을 사용해 배열 안에 값이 있는지 확인해주면 해결 가능하다. 주의사항 a의 경우는 M안에 a에 해당하는 값이 있는 지 찾기 위한 용도로 사용될 것이기 때문에 a의 값을 사용할 일이 없어 set으로 받는다. 그렇지 않으면 시간 초과로 인해 문제를 해결할 수 없다. import sys input=sys.stdin.readline n = int(input()) a = set(map(int,input().split())) m = int(input()) M = list(map(int,input().split())) for i in range(len(M)): if M[i] in a: print(1) else: print(0)
1026번 보물 문제는 입력받은 n개의 A,B 배열을 알맞게 정렬하여 S = A[0] * B[0] + ... + A[n-1] * B[n-1] 의 최솟값을 구하는 문제이다. 문제를 해결하기 위해 A를 재배열 해야하지만 B는 재배열 할 수 없다. 나는 해당 문제를 A,B 모두 재배열 하지 않고 풀 수 있는 방법을 찾아 그렇게 해결했다. n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) s=0 for i in range(n): s+= min(a) * max(b) a.pop(a.index(min(a))) b.pop(b.index(max(b))) print(s) int형태 list로 a,b를 입력받고 a의 가..
read = int(input()) ub = '____' cnt = 0 def recursive(cnt): print('{}"재귀함수가 뭔가요?"'.format(ub*cnt)) if(cnt == read): print('{}"재귀함수는 자기 자신을 호출하는 함수라네"'.format(ub*cnt)) else: print('{}"잘 들어보게. 옛날옛날 한 산 꼭대기에 이세상 모든 지식을 통달한 선인이 있었어.'.format(ub*cnt)) print('{}마을 사람들은 모두 그 선인에게 수많은 질문을 했고, 모두 지혜롭게 대답해 주었지.'.format(ub*cnt)) print('{}그의 답은 대부분 옳았다고 하네. 그런데 어느 날, 그 선인에게 한 선비가 찾아와서 물었어."'.format(ub*cnt)) ..