-
[백준] 13458번_시험감독Study/알고리즘 2020. 1. 24. 13:48
문제 링크 : https://www.acmicpc.net/problem/13458
13458번: 시험 감독
첫째 줄에 시험장의 개수 N(1 ≤ N ≤ 1,000,000)이 주어진다. 둘째 줄에는 각 시험장에 있는 응시자의 수 Ai (1 ≤ Ai ≤ 1,000,000)가 주어진다. 셋째 줄에는 B와 C가 주어진다. (1 ≤ B, C ≤ 1,000,000)
www.acmicpc.net
import sys import math n = int(sys.stdin.readline()) students = list(map(int,sys.stdin.readline().rstrip().split())) b,c = list(map(int,input().split())) count = 0 for student in students: # 총감독관 student -= b count += 1 if student <= 0: continue # 부감독관 else: count += math.ceil(student/c) sys.stdout.write(str(count))
시간이 상당히 오래걸리는구만..
+ ceil함수때문에 오래걸리는가 싶어서
import sys n = int(sys.stdin.readline()) students = list(map(int,sys.stdin.readline().rstrip().split())) b,c = list(map(int,input().split())) count = 0 for student in students: # 총감독관 student -= b count += 1 if student <= 0: continue # 부감독관 else: count += student//c if student % c != 0: count += 1 sys.stdout.write(str(count))
이렇게 해봤는데 시간이 줄긴 했지만 별 차이는 없었다.
'Study > 알고리즘' 카테고리의 다른 글
[백준] 2231번_분해합 (0) 2020.01.28 [백준] 2798번_블랙잭 (0) 2020.01.28 [백준] 2668번_숫자고르기 (0) 2020.01.22 [백준] 1652번_누울자리를찾아라 (0) 2020.01.21 [백준] 1759번_암호만들기 (0) 2020.01.17