Skip to content

Commit

Permalink
feat: add 23351
Browse files Browse the repository at this point in the history
  • Loading branch information
owl1753 committed Aug 4, 2024
1 parent ddac4e7 commit 4ad4eae
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
| 8/1 | [2016 Arab Collegiate Programming Contest](https://www.acmicpc.net/category/detail/2188) | [18691](https://www.acmicpc.net/problem/18691) | 수학 |
| 8/2 | | **_[1247](https://www.acmicpc.net/problem/1247)_** | 큰 수 연산 |
| 8/3 | | **_[2338](https://www.acmicpc.net/problem/2338)_** | 큰 수 연산 |
| 8/4 | | | |
| 8/4 | [제1회 한국항공대학교 프로그래밍 경진대회(KAUPC)](https://www.acmicpc.net/category/detail/2838) | [23351](https://www.acmicpc.net/problem/23351) | 그리디 |
| 8/5 | | | |
| 8/6 | | | |
| 8/7 | | | |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <iostream>
#include <vector>
using namespace std;

int main() {
int N, K, A, B, result = 0;
vector<int> leaves;
cin >> N >> K >> A >> B;
for (int i = 0; i < N; i++) leaves.push_back(K);

while (true) {
result++;
int minValue = 987654321;
int minIndex = 0;
for (int i = 0; i < leaves.size() - A + 1; i++) {
int sum = 0;
for (int j = i; j < i + A; j++) sum += leaves[j];
if (sum < minValue) {
minIndex = i;
minValue = sum;
}
}
for (int i = minIndex; i < minIndex + A; i++) leaves[i] += B;
bool flag = false;
for (int i = 0; i < leaves.size(); i++) {
leaves[i]--;
if (leaves[i] <= 0) flag = true;
}
if (flag) break;
}

cout << result;
}

0 comments on commit 4ad4eae

Please sign in to comment.