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 | 31 | 
													Tags
													
											
												
												- 영어회화
- XML
- 오픽
- 영어말하기
- 메모이제이션
- dynamicProgramming
- stack 스택
- dp
- 이진탐색
- 이진탐색 #나무 자르기
- 오픽공부법
- 오픽점수잘받는방법
- 오픽노잼공부방법
- 오픽가격
- 오픽노잼
- topdown
- ㅂ
- XML주석
- 안드로이드
- fibo
- opic
- 피보나치수열
- 주석
- 안드로이드주석
- 디피
- 다이나믹프로그래밍
- 바텀업
- English
- 탑다운
													Archives
													
											
									RUBY
[BOJ] 시험 감독 | 삼성 본문
출처:: https://www.acmicpc.net/problem/13458
1. 문제 이해 및 해결과정
1. 각 시험장의 응시자 수를 배열에 넣음
2. 각 응시자 수를 총 감독 인원 수로 나눠서 CNT+=몫
3. 응시자 수에서 총감독이 감독한 인원 뺌
4. 응시자 수에서 총 감독 인원수 뺀 값에서 부감독 인원수로 나눈 몫의 올림을 더함 CNT+= 몫의 올림


*주의할 점
-시험장 수 * 각 시험장의 최대 학생수 = 10^ 12 ->int형 범위 넘음 => total은 long long %lld 써야함
2. 풀이방법
1. ceil 올림 함수 이용
#if 01
//시험 감독
//https://www.acmicpc.net/problem/13458
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
vector <int> v;
int N,B,C;
long long total; 
void Solve() {
	for (int i = 0; i < N; i++) {
		total++; //총감독관
	
		v[i] -= B;
		
		if(v[i]>=0)total += (ceil((double)v[i] / C));
	}
}
int main() {
	freopen("input.txt", "r", stdin);
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		int people;
		scanf("%d", &people);
		v.push_back(people);
	}
	scanf("%d %d", &B, &C);
	Solve();
	printf("%lld", total);
	return 0;
}
#endif
2. 올리는 경우 직접구현
void Solve() {
	for (int i = 0; i < N; i++) {
		total++; //총감독관
	
		v[i] -= B;
		
		//if(v[i]>=0)total += (ceil((double)v[i] / C));
		if (v[i] > 0) {
			total += (v[i] / C);
			if (v[i] % C != 0) {
				total++;
			}
		}
	}
}3. python
#시험감독
#https://www.acmicpc.net/problem/13458
import sys
sys.stdin = open("input.txt","r")
n=int(input()) #시험장
arr=list(map(int,input().split()))
main,sub=map(int,input().split())
sol=0
for x in arr:
    if x>=main: #총감독보다 시험보는 인원이 많으면
        x-=main
        if x%sub==0:
            sol+=x//sub
        else:
            sol+=x//sub + 1
print(sol + len(arr))
3. 오답원인
4. 알게된 점
'PS > BOJ' 카테고리의 다른 글
| [백준] 줄세우기 (0) | 2020.09.15 | 
|---|---|
| [백준] 드래곤 커브 | 삼성 (0) | 2020.09.14 | 
| [백준] 게리맨더링2 | 삼성 (0) | 2020.09.11 | 
| [백준] 감시 | 삼성 (0) | 2020.09.09 | 
| [백준] 치즈 (0) | 2020.09.02 | 
			  Comments
			
		
	
               
           
					
					
					
					
					
					
				 
             
								