kunkunwoo@blog:~$ 거누권의 생각깜지

백준 13458번 _ 시험 감독

· 배운 것 · 2분 읽기

https://www.acmicpc.net/problem/13458

13458번: 시험 감독

풀이방법

이거 외에는 없다. 시간도 O(N)이라 충분하다.


전체 코드

#include <iostream>
#include <algorithm>
#include <vector>

#define LL long long

using namespace std;

int main()
{
	vector<int> rooms;
	int n;
	cin >> n;
	int value;
	for (int i = 0; i < n; i++)
	{
		cin >> value;
		rooms.push_back(value);
	}

	int b, c;
	cin >> b >> c;
	LL cnt = n;
	for (auto& attender : rooms)
	{
		int lastAttender = (attender - b);

		if (lastAttender <= 0)
			continue;

		if (lastAttender % c == 0)
			cnt += (lastAttender / c);
		else
			cnt += ((lastAttender / c)+1);
	}
	cout << cnt << endl;

	return 0;
}

후기

꿀이다