본문 바로가기

sort16

백준 2303 숫자 게임 https://www.acmicpc.net/problem/2303 2303번: 숫자 게임 N명이 모여 숫자 게임을 하고자 한다. 각 사람에게는 1부터 10사이의 수가 적혀진 다섯 장의 카드가 주어진다. 그 중 세 장의 카드를 골라 합을 구한 후 일의 자리 수가 가장 큰 사람이 게임을 이 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 from itertools import combinations n=int(input()) answer=[] for i in range(n): nums = list(map(int, input().split())) mymax=0 for nums_com in (list(combinations(nums, 3))): if mymax 2022. 10. 27.
백준 1026 보물 https://www.acmicpc.net/problem/1026 1026번: 보물 첫째 줄에 N이 주어진다. 둘째 줄에는 A에 있는 N개의 수가 순서대로 주어지고, 셋째 줄에는 B에 있는 수가 순서대로 주어진다. N은 50보다 작거나 같은 자연수이고, A와 B의 각 원소는 100보다 작거 www.acmicpc.net def sol(nums1,nums2): answer=0 for i in range(len(nums1)): answer+=nums1[i]*nums2[i] return answer n=int(input()) nums1=sorted(list(map(int,input().split()))) nums2=sorted(list(map(int,input().split())), reverse=True) p.. 2022. 10. 19.
백준 2993 세 부분 def sol(s): len_s = len(s) strings = [] for i in range(1, len_s - 1): for j in range(1, len_s - 1): if i + j 2022. 10. 18.
백준 2535 아시아 정보올림피아드 https://www.acmicpc.net/problem/2535 2535번: 아시아 정보올림피아드 첫 번째 줄에는 대회참가 학생 수를 나타내는 N이 주어진다. 단, 3 ≤ N ≤ 100이다. 두 번째 줄부터 N개의 줄에는 각 줄마다 한 학생의 소속 국가 번호, 학생 번호, 그리고 성적이 하나의 빈칸을 사 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 def sol(n,nums): nums.sort(key=lambda x: x[2],reverse=True) nations=[0]*n cnt=0 for i in range(len(nums)): if cnt==3: break if nations[nums[i][0]]!=2: nations[nums[i][0]]+.. 2022. 10. 18.
백준 23278 영화 평가 https://www.acmicpc.net/problem/23278 23278번: 영화 평가 스타트링크에는 영화 감상 동아리가 있다. 영화 동아리에는 총 N명의 구성원이 있고, 매주 모여서 영화 한 편을 본다. 영화를 본 뒤, 각 사람은 0보다 크거나 같고, 100보다 작거나 같은 정수로 영 www.acmicpc.net 1 2 3 4 n,l,h=map(int, input().split()) scores=sorted(list(map(int, input().split()))) ans=sum(scores[l:n-h])/(n-l-h) print(ans) Colored by Color Scripter cs 점수들이 최대 100이하고 숫자들 개수가 엄청 많았다면 계수정렬을 썼겠지만 그렇지 않으므로 내부함수를 사용해.. 2022. 10. 17.
백준 25496 장신구 명장 임스 https://www.acmicpc.net/problem/25496 25496번: 장신구 명장 임스 첫 번째 줄에 정수 $P$와 정수 $N$이 공백으로 구분되어 주어진다. ($1 \le P \le 200$, $1 \le N \le 1\,000$) 두 번째 줄에는 정수 $A_1, A_2, \dots, A_N$이 공백으로 구분되어 주어진다. ($1 \le A_i \le 200$) www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 def sol(p,n,nums): nums.sort() answer = 0 for i in range(n): if p 2022. 10. 17.
백준 1251 단어 나누기 https://www.acmicpc.net/problem/1251 1251번: 단어 나누기 알파벳 소문자로 이루어진 단어를 가지고 아래와 같은 과정을 해 보려고 한다. 먼저 단어에서 임의의 두 부분을 골라서 단어를 쪼갠다. 즉, 주어진 단어를 세 개의 더 작은 단어로 나누는 것이다 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 def sol(s): len_s = len(s) strings = [] for i in range(1, len_s - 1): for j in range(1, len_s - 1): if i + j 2022. 10. 17.
백준 17335 APC는 왜 서브태스크 대회가 되었을까? https://www.acmicpc.net/problem/17224 17224번: APC는 왜 서브태스크 대회가 되었을까? 2019년 올해도 어김없이 아주대학교 프로그래밍 경시대회(Ajou Programming Contest, APC)가 열렸다! 올해 새롭게 APC의 총감독을 맡게 된 준표는 대회 출제 과정 중 큰 고민에 빠졌다. APC에 참가하는 참가 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 def sol(l,k,score,problems,is_hard): if is_hard==1: plus_score=140 location=1 else: plus_score=100 location=0 problem.. 2022. 10. 14.
백준 16466 콘서트 https://www.acmicpc.net/problem/16466 16466번: 콘서트 HCPC (Hanyang Completely Perfect Celebrity)는 한양대학교 최고의 가수에게 주어지는 칭호이다. 한양대학교는 매년 최고의 HCPC를 선발한다. HCPC가 되기란 여간 어려운 게 아니다. 매일 아침 날달걀을 까먹 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 import sys n=int(sys.stdin.readline()) nums=sorted(list(map(int, sys.stdin.readline().split()))) is_full=1 for i in range(len(nums)): if (i+1)!=nums[i]: print(i+1) is_full=0.. 2022. 10. 13.
백준 22993 서든어택 3 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import sys n=int(sys.stdin.readline()) tmp1=(list(map(int, sys.stdin.readline().split()))) jun=tmp1[0] tmp1.pop(0) tmp1.sort() for i in tmp1: if i 2021. 8. 26.
백준 16471 작은 수 내기 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import sys n=int(sys.stdin.readline()) tmp1=sorted(list(map(int, sys.stdin.readline().split()))) tmp2=sorted(list(map(int, sys.stdin.readline().split()))) tmp1.reverse() cnt=0 for i in tmp1: if i>=tmp2[-1]: pass else: cnt+=1 tmp2.pop() if cnt> n//2: print("YES") else: print("NO") Colored by Color Scripter cs 우선 카드를 정렬을 하구 주언이 가지고있는 카드중 제일큰 카드가 사장이 가지고있는 카드 중 제일 큰.. 2021. 8. 26.
백준 16435 스네이크버드 1 2 3 4 5 6 7 8 import sys n,l=map(int, sys.stdin.readline().split()) h=list(map(int, sys.stdin.readline().split())) h.sort() for i in h: if l>=i: l+=1 else:break print(l) Colored by Color Scripter cs 그리디 알고리즘이구요 스네이크버드의 길이를 최대화 하고싶다-> 작은것부터 먹어야함 2021. 8. 26.