# 백준 10810 - 공 넣기
bucketSize,balls=map(int,input().split(" "))# 바구니(양동이)와 공의 갯수를 정해줌
buckets=[0]*(bucketSize)# buckets 라는 1차원 배열을 선언하고 숫자 0을 bucektSize만큼 추가함
for_inrange(balls):# 반복문에 반복숫자를 사용할 일이 없으면 _(언더바) 사용
i,j,k=map(int,input().split(" "))# i바구니 ~ j바구니, 공의 숫자 k
forxinrange(i,j+1):buckets[x-1]=k# 배열의 인덱스는 0부터 시작하므로 1을 빼줌, 만약 이 1도 거슬린다면 배열의 갯수 자체를 bucketSize+1을 해주면 print할 때 문제는 없음
forbucketinbuckets:print(bucket,end=" ")# 문자의 끝을 기본인 개행문자(\n)이 아닌 " "(공백)으로 바꿔줌
10813 - 공 바꾸기
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 백준 10813 - 공 바꾸기
N,M=map(int,input().split(" "))buckets=[]foriinrange(0,N+1):buckets.append(i)# 바구니의 자리에 바구니 번호에 맞는 숫자를 넣어줌
for_inrange(M):i,j=map(int,input().split(" "))# 바꿀 바구니의 번호 입력
temp=buckets[i]buckets[i]=buckets[j]buckets[j]=tempbuckets.remove(0)# 배열의 첫 번째 인덱스 0을 없애줌
forbucketinbuckets:print(bucket,end=" ")
5597 - 과제 안 내신 분..?
1
2
3
4
5
6
7
8
9
10
11
12
13
# 백준 5597 - 과제 안 내신 분..?
students=[]foriinrange(31):students.append(i)students.remove(0)foriinrange(28):n=int(input())students.remove(n)print(min(students))print(max(students))
3052 - 나머지
1
2
3
4
5
6
7
# 백준 3052번 - 나머지
arr1=[]foriinrange(0,10):arr1.append(int(input())%42)print(len(set(arr1)))
# 백준 1546번 - 평균
subjectCnt=int(input())# 시험 본 과목의 개수 N
tempScore=list(map(int,input().split(" ")))maxScore=max(tempScore)newList=[]forscoreintempScore:newList.append(score/maxScore*100)avg=sum(newList)/subjectCntprint(avg)
댓글남기기