This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
typedef long long ll;
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n, a, b, c;
std::string s;
std::cin >> n >> s >> a >> b >> c;
ll ans = n * a;
for (ll i = 1; i < n; ++i) {
ll max_parts = n / i;
for (ll parts = 1; parts <= max_parts; ++parts) {
ll cost = i * a;
if (parts > 1) {
cost += b + parts * c;
}
cost += (n - (parts * i)) * a;
ans = std::min(ans, cost);
}
}
std::cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |