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 |
Tags
- 완전탐색
- 알고리즘
- java
- 다이나믹프로그래밍
- 세그먼트트리
- 취득후기
- 시뮬레이션
- dp
- YBMCOS
- 이젠 골드구현도 어렵네..
- 게더타운시작
- BFS
- deque
- 재귀함수
- QUICKSTARTGUIDE
- 백준코딩테스트
- 엘라스틱서치
- 백준
- GatherTown
- DFS
- 01BFS
- 자바PS
- spring
- 구현
- COSPROJAVA1급
- 다익스트라
- PS
- 우선순위큐
- 네트워크플로우
- COSPRO
Archives
- Today
- Total
공부공간
BOJ - 13458 ) 시험감독 본문
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
N개의 방에 필요한 최소 시험감독의 수를 구하는 문제이다.
무조건 i번째 방에는 1 명의 총감독이 필요하므로 총감독이 감독할 수 있는 시험자의 수를 제외하고
나머지 사람들을 부감독이 감시할 수 있는 사람의 수로 나누어서 부감독의 사람수를 구한다.
간단한 메모제이션을 통하여, 이전에 구했던 시험자 수에대해서 다시구하지 않도록 처리해주자.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int max = 1000001;
int N = Integer.parseInt(st.nextToken());
int person[] = new int[N];
st = new StringTokenizer(br.readLine());
for(int index = 0 ; index < N ;index++) person[index] = Integer.parseInt(st.nextToken());
st = new StringTokenizer(br.readLine());
int B = Integer.parseInt(st.nextToken());
int C = Integer.parseInt(st.nextToken());
int Memo[] = new int[max];
long answer= 0;
int cnt=1;
for(int index = 0 ; index < N ; index++) {
if(Memo[person[index]]!=0) {
answer +=Memo[person[index]];
continue;
}
cnt=1;
if(person[index]-B > 0) {
cnt +=((person[index]-B)/C);
if((person[index]-B)%C != 0 ) cnt++;
}
Memo[person[index]] = cnt;
answer += cnt;
}
System.out.println(answer);
}
}
'알고리즘 > 구현,시뮬' 카테고리의 다른 글
BOJ - 14891 ) 톱니바퀴 (0) | 2020.03.08 |
---|---|
BOJ - 3190 ) 뱀 (0) | 2020.03.07 |
BOJ - 16235 ) 나무 재테크 (0) | 2020.02.28 |
BOJ - 17144 ) 미세먼지 안녕! (0) | 2020.02.26 |
BOJ- 17143 ) 낚시왕 (0) | 2020.02.26 |
Comments