C++)
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, temp;
cin >> n;
vector<int> v;
for (int i = 0; i < n; i++) {
cin >> temp;
v.push_back(temp);
}
int b, c;
cin >> b >> c;
long long ans = n;
for (auto num : v) {
if (num - b > 0) {
ans += ( (num-b)%c == 0) ? (num-b)/c : (num-b)/c+1;
}
}
cout << ans;
return 0;
}
Python)
import sys
import math
read = sys.stdin.readline
n = int(read().rstrip())
arr = list(map(int, read().rstrip().split()))
b, c = map(int, read().rstrip().split())
# 총 감독관 1명은 무조건 있어야함
ans = n
for num in arr:
ans += (math.ceil((num-b)/c) if num - b > 0 else 0)
print(int(ans))
주의 : 총험장의 인원수 < 총감독관이 감시할 수 있는 인원수
5
100 100 100 100 100
1000 5
5
'백준 1 > 구현' 카테고리의 다른 글
| [백준 2960] 에라토스테네스의 체 (C++/Python) (0) | 2020.12.06 |
|---|---|
| [백준 2839] 설탕 배달 (C++/Python) (0) | 2020.12.06 |
| [백준 1924] 2007년 (C++/Python) (0) | 2020.12.06 |