[코드트리] 바이러스 검사

rhkr9080·2023년 7월 14일
0

코드트리

목록 보기
3/29

문제링크 : https://www.codetree.ai/training-field/frequent-problems/problems/virus-detector/description?page=1&pageSize=20

💻 문제 풀이 : C++

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

using namespace std;

#define ll long long

int main()
{
	int N;
	cin >> N;

	vector<int> client;
	for (int i = 0; i < N; i++)
	{
		int num;
		cin >> num;
		client.push_back(num);
	}
	int a, b;
	cin >> a >> b;

	ll count = 0;
	for (int i = 0; i < N; i++)
	{
		int tmp = client[i];
		if (a >= tmp)
		{
			count++;
		}
		else
		{
			tmp -= a;
			count++;
			if (tmp % b == 0)
			{
				count += tmp / b;
			}
			else
			{
				count += tmp / b;
				count++;
			}
		}
	}

	cout << count << "\n";

	return 0;
}

📌 memo 😊

profile
공부방

0개의 댓글