#include <bits/stdc++.h>
using namespace std;
long long dp[2501][2501],n,a,b,c;
string s;
long long solve(int i,int cu){
if(i==n){
return 0;
}
if(dp[i][cu]!=-1)return dp[i][cu];
long long c1 = solve(i+1,cu)+a;
if(cu&&i+cu<=n)c1 = min(c1,solve(i+cu,cu)+c);
if(i>cu)c1 = min(c1,solve(0,i)+b);
return dp[i][cu] = c1;
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
memset(dp,-1,sizeof dp);
cin>>n>>s>>a>>b>>c;
cout<<solve(0,0)<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
49240 KB |
Output is correct |
2 |
Correct |
6 ms |
49244 KB |
Output is correct |
3 |
Incorrect |
6 ms |
49244 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
49244 KB |
Output is correct |
2 |
Correct |
6 ms |
49368 KB |
Output is correct |
3 |
Correct |
80 ms |
49620 KB |
Output is correct |
4 |
Correct |
86 ms |
49808 KB |
Output is correct |
5 |
Correct |
99 ms |
49668 KB |
Output is correct |
6 |
Correct |
118 ms |
49688 KB |
Output is correct |
7 |
Correct |
135 ms |
49752 KB |
Output is correct |
8 |
Correct |
138 ms |
49712 KB |
Output is correct |
9 |
Correct |
144 ms |
49708 KB |
Output is correct |
10 |
Correct |
6 ms |
49496 KB |
Output is correct |
11 |
Correct |
6 ms |
49292 KB |
Output is correct |
12 |
Correct |
6 ms |
49288 KB |
Output is correct |
13 |
Correct |
7 ms |
49368 KB |
Output is correct |
14 |
Correct |
6 ms |
49244 KB |
Output is correct |
15 |
Correct |
7 ms |
49244 KB |
Output is correct |
16 |
Correct |
6 ms |
49240 KB |
Output is correct |
17 |
Correct |
7 ms |
49756 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
49240 KB |
Output is correct |
2 |
Correct |
6 ms |
49244 KB |
Output is correct |
3 |
Incorrect |
6 ms |
49244 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
49240 KB |
Output is correct |
2 |
Correct |
6 ms |
49244 KB |
Output is correct |
3 |
Incorrect |
6 ms |
49244 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
49240 KB |
Output is correct |
2 |
Correct |
6 ms |
49244 KB |
Output is correct |
3 |
Incorrect |
6 ms |
49244 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
49240 KB |
Output is correct |
2 |
Correct |
6 ms |
49244 KB |
Output is correct |
3 |
Incorrect |
6 ms |
49244 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |