전체
임시
import sys N = int(sys.stdin.readline()) ary=[] for i in range(N): ary.append(int(sys.stdin.readline())) full = N cnt = 0 result=[] def dfs(i,cnt,full,sum): while True: if full==2: if cnt!=0: sum+=ary[i+1] else: sum+=(ary[i]+ary[i+1]) result.append(sum) break //4번째일때 해당 else: if cnt < 2: cnt+=1 full-=1 sum+=ary[i] dfs(i+1,cnt,full,sum) sum-=ary[i] cnt-=1 full+=1 else: full-=1 dfs(i+1,0,full,sum)..
2108번
counter 나중에 쓸일 있으니 알아두기. 최대 빈도 이용하는 문제에 이용 가능 import sys from collections import Counter N = int(sys.stdin.readline()) a = [int(sys.stdin.readline()) for i in range(N)] a.sort() a_num = Counter(a).most_common() print('%.f'%(sum(a)/N)) print(a[N//2]) if len(a)>1: if a_num[0][1] == a_num[1][1]: print(a_num[1][0]) else: print(a_num[0][0]) else: print(a[0]) print(a[N-1]-a[0])
10989
memory를 줄이기 위해 초기 메모리를 설정 input은 시간이 오래걸리므로 system의 stdin.readline을 이용해서 데이터를 입력 받아옴 import sys N = int(sys.stdin.readline()) a = [0]*10001 for i in range(N): a[int(sys.stdin.readline())]+=1 for i in range(10001): if a[i] !=0: for j in range(a[i]): print(i)
1436번
N = int(input()) num = 666 count =0 while 1: if '666' in str(num): count+=1 if count == N: print(num) break num+=1 """ for i in range(5): for j in range(5): if i==0: if j==0: a.append(666) else: for k in range(10**j): k = str(k) a.append(int('666'+'0'*(j-len(k))+k)) elif j==0: for k in range(10**(i-1),10**i): k = str(k) a.append(int(k+'666')) else: for p in range(10**(i-1),10**i): p=str(p) for q..
7568
N = int(input()) name = [] rank = [1]*N for i in range(N): x,y = map(int, input().split()) name.append([x,y]) for i in range(0,N): for j in range(0,N): if name[i][0] < name[j][0] and name[i][1] < name[j][1]: rank[i]+=1 rank = map(str, rank) print(' '.join(rank))