<Algorithm> 83. 13458번 시험감독
by BFine반응형
1. 13458번 시험감독
문제에 대한 이해를 잘했는지에 대한 문제인 것 같다.
무조건 int형으로 하려고 하지말고 long형에 대한 부분도 생각을 해야 할 것 같다.
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { static long count = 0; public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); int[] people = new int[N]; StringTokenizer st = new StringTokenizer(br.readLine()); for(int i = 0; i < N ; i++) { people[i] = Integer.parseInt(st.nextToken()); } st = new StringTokenizer(br.readLine()); int m = Integer.parseInt(st.nextToken()); int s = Integer.parseInt(st.nextToken()); int cnt = 0; for(int i = 0; i < N ; i++) { people[i] -=m; if(people[i] <= 0) { cnt++; } count++; } if(cnt == N) { System.out.println(N); return; } for(int i = 0; i < N ; i++) { if(people[i]<= 0) continue; int quo = people[i]/s; count += quo; int rem = people[i]%s; if(rem !=0) { count++; } } System.out.println(count); } } | cs |
참고 & 출처
블로그의 정보
57개월 BackEnd
BFine