13458 Samsung sw test
์๊ณ ๋ฆฌ์ฆ
1. ์ค์ง 1๋ช
์ ๋ฌด์กฐ๊ฑด 1๋ช
์์ด์ผํ๋ค๋ ๋ง
2. ์ด๊ฐ๋
๊ด์ด ๊ฐ์ํ ์ ์๋ ์์์ ์๋งํผ ๋นผ๊ณ , ๊ฐ๋
๊ด ์ 1๋ช
๋๋ฆฐ๋ค์์, ๋ฃ์ด์ผํ๋ ๋ถ๊ฐ๋
๊ด ์๋ฅผ ๋ํจ. -> ์ด๋ฅผ ๋ชจ๋ ์ํ์ฅ์ ์ ์ฉ
3. ์ด๋ ์ด ํ์ํ ๊ฐ๋
๊ด์ ์ ์ฅํ๋ ๋ณ์๋ long long์ผ๋ก ํด์ผํจ(์์์ ์ 100๋ง๋ช
, ์ํ์ฅ ์ 100๋ง๊ฐ ์ด๋ฏ๋ก)
์ฝ๋
#include <iostream>
#define MAX_CLASS 1000000
using namespace std;
int testClass[MAX_CLASS];
int numOfClass;
int chief;
int second;
int main() {
cin >> numOfClass;
for (int i = 0; i < numOfClass; i++)
cin >> testClass[i];
cin >> chief >> second;
long long need = numOfClass;
for (int i = 0; i < numOfClass; i++) {
testClass[i] -= chief;
if (testClass[i] <= 0)
continue;
int temp = testClass[i] / second;
need += temp;
testClass[i] -= temp * second;
need += (testClass[i] > 0 ? 1 : 0);
}
cout << need;
}