Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 가민 인터벌 러닝
- 10k 마라톤
- 의정부시청역 콩나물국밥
- 의정부 전주콩나물국밥
- github command
- 신대방삼거리역 홍어
- 가민
- 신대방삼거리역 흑산도홍어
- Garmin Chronos
- java lombok
- java 알고리즘
- 가민 크로노스 러닝
- 마라톤
- 신설동역 맛집
- Running 연습
- 알고리즘
- 10KM 러닝
- 가민 크로노스 인터벌 러닝
- 서울 흑산도홍어
- 러너
- 의정부역 콩나물국밥
- 서울 홍어삼합
- 인터벌 러닝
- MongoDB mongoimport
- 인터벌러닝
- 가민 크로노스
- lombok
- 의정부 콩나물국밥 맛집
- MongoDB foreach
- 의정부 전주본가
Archives
- Today
- Total
나의 Winding Road
BAEKJOON 13458번: 시험 감독 본문
[2017-04-09 일요일]
* 내용: 시험 감독 문제
1. 문제
2. 해결 방법
1. 문제
* 내용
- URL: https://www.acmicpc.net/problem/13458
- 문제
2. 해결 방법
* 이슈: 계속해서 63%에서 실패하는 현상
- 원인: 결과를 담는 변수의 크기(int: 4바이트)가 작아서 실패
- 해결 방법: 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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | import java.util.Scanner; import static java.lang.System.in; /** * Created by K on 2017-04-09. */ public class Practice1 { public static void main(String agrs[]) { Scanner scanner = new Scanner(in); int classNum = 0; int[] studentNum; int profOverseeNum; int secondProfOverseeNum; if(scanner.hasNextInt()) classNum = scanner.nextInt(); else return ; if(1 > classNum || classNum > 1000000) return ; studentNum = new int[classNum]; for(int i = 0; i < classNum; i++){ if(scanner.hasNextInt()) studentNum[i] = scanner.nextInt(); else return ; if(1 > studentNum[i] || studentNum[i] > 1000000) return ; } if(scanner.hasNextInt()) profOverseeNum = scanner.nextInt(); else return ; if(1 > profOverseeNum || profOverseeNum > 1000000) return ; if(scanner.hasNextInt()) secondProfOverseeNum = scanner.nextInt(); else return ; if(1 > secondProfOverseeNum || secondProfOverseeNum > 1000000) return ; InputHandler inputHandler = new InputHandler(classNum, studentNum, profOverseeNum, secondProfOverseeNum); if(inputHandler.checkInputs() == true) { inputHandler.execProcess(); System.out.print(inputHandler.getResultNum()); } return ; } } class InputHandler { public int classNum; public int[] studentNum; public int profOverseeNum; public int secondProfOverseeNum; public long resultNum; public long getResultNum() { return resultNum; } public InputHandler(int classNum, int[] studentNum, int profOverseeNum, int secondProfOverseeNum) { this.classNum = classNum; this.studentNum = studentNum; this.profOverseeNum = profOverseeNum; this.secondProfOverseeNum = secondProfOverseeNum; } public boolean checkInputs() { if(1 > classNum || classNum > 1000000) return false; for(int temp : studentNum) { if(1 > temp || temp > 1000000) return false; } if(1 > profOverseeNum || profOverseeNum > 1000000) return false; if(1 > secondProfOverseeNum || secondProfOverseeNum > 1000000) return false; return true; } public void execProcess() { this.resultNum = 0; for(int i = 0; i < classNum; i++) { resultNum++; int remainStNum = studentNum[i] - profOverseeNum; if(remainStNum <= 0) continue; else { resultNum++; int secondProfNum = remainStNum / secondProfOverseeNum; if(remainStNum % secondProfOverseeNum == 0) resultNum = resultNum + secondProfNum - 1; else { resultNum = resultNum + secondProfNum; } } } } } | cs |
'개발 > Algorithm' 카테고리의 다른 글
BAEKJOON 10825번: 국영수 (0) | 2018.09.04 |
---|---|
BAEKJOON 9465번: 스티커 (0) | 2018.09.02 |
BAEKJOON 1463번: 1로 만들기 (0) | 2018.08.30 |
로봇 청소기 (0) | 2017.04.17 |
BAEKJOON 1260번: DFS와 BFS (1) | 2017.04.17 |