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>
using namespace std;
using ll = long long;
int n;
string s;
ll a, b, c;
ll dp[3000];
int main() {
cin >> n >> s >> a >> b >> c;
dp[1] = a;
for(int i=2;i<=n;i++) {
dp[i] = 1ll*i*a;
for(int j=1;j<i;j++)
dp[i] = min(dp[i], dp[j] + b + (i/j)*c + (i%j)*a);
}
cout << dp[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... |