Development Project

[ Baekjoon - 단계별로 풀어보기(05/27) ] - 4단계 : 1차원 배열 본문

CodingTest/Baekjoon

[ Baekjoon - 단계별로 풀어보기(05/27) ] - 4단계 : 1차원 배열

나를 위한 시간 2022. 5. 28. 00:11
  • 10818 : 최소, 최대
numberOf = int(input())
nums = list(map(int, input().split()))
min=nums[0]
max=nums[0]
for i in range(1, numberOf):
    min = nums[i] if nums[i]<min else min
    max = nums[i] if nums[i]>max else max
print(min, max)
#
num = int(input())
nums = list(map(int,input().split()))
print(min(nums),max(nums))

 

  • 2562 : 최댓값
num1 = int(input())
cnt=1
for i in range(8):
    num2 = int(input())
    if num1<num2:
        num1=num2
        cnt=i+2
print(str(num1)+"\n"+str(cnt))
#
num = []
for i in range(9):
    num.append(int(input()))
print(max(num))
print(num.index(max(num))+1)
#
nums = list(int(input()) for _ in range(9))
index = nums.index(max(nums)) + 1
print(str(max(nums))+"\n"+str(index))

 

  • 2577 : 숫자의 개수
inputNum = list(int(input()) for _ in range(3))
n_list = list(map(int, str(inputNum[0]*inputNum[1]*inputNum[2])))
cnt_list = []
for i in range(10):
    cnt=0
    for j in n_list:
        if i==j:
            cnt+=1
    cnt_list.append(cnt)
for value in (cnt_list[i] for i in range(10)):
    print(value)
#
nums = list(int(input()) for _ in range(3))
for i in range(10):
    print(str(nums[0]*nums[1]*nums[2]).count(str(i)))

 

  • 3052 : 나머지
nums = list(int(input()) for _ in range(10))
rest = [nums[0]%42]
for i in nums:
    cnt=0
    for j in range(len(rest)):
        if rest[j]==i%42:
            break
        cnt+=1
        if len(rest)==j+1:
            rest.append(i%42)
print(len(rest))
#
cnt_list = [0 for i in range(42)]  #cnt_list = [0]*42
ans = 0
for i in range(10):
    a=int(input())
    cnt_list[a%42]+=1
for j in range(42):
    if cnt_list[j]>0:
        ans+=1
print(ans)

 

  • 1546 : 평균
n = int(input())
x = list(map(int,input().split()))
print(sum(x)/n/max(x)*100)

 

  • 8958 : OX퀴즈
n = int(input())
p_list = list(input() for _ in range(n))
for i in range(len(p_list)):
    x_idx = [j for j in range(len(p_list[i])) if p_list[i][j]=="X"]
    x_idx.append(len(p_list[i]))
    total=0

    start = -1
    for x in x_idx:
        cnt = x-start-1
        if cnt!=0:
            for j in range(1,cnt+1):
                total+=j
        start=x
    print(total)
#
T = int(input())
for j in range(T):
    ox = input()
    res = 0
    add = 0
    for i in ox:
        if i == "O":
            add += 1
        else:
            add = 0
        res += add
    print(res)

 

  • 4344 : 평균은 넘겠지
all_n=int(input())
for i in range(all_n):
    scores=list(map(int, input().split()))
    
    n=scores[0]
    scores=scores[1:]
    
    res = [x for x in scores if x>(sum(scores)/n)]
    print(f"{len(res)/len(scores)*100:.3f}%")
#
num = int(input())
for a in range(num):
    n = list(map(int, input().split()))
    cnt = 0
    avg = sum(n[1:])/n[0]
    for i in n[1:]:
        if i > avg:
            cnt+=1
    print(f'{cnt/n[0]*100:.3f}%')

 

 

 

 

Comments