Submission #887515

# Submission time Handle Problem Language Result Execution time Memory
887515 2023-12-14T16:56:02 Z Ahmed57 Copy and Paste 3 (JOI22_copypaste3) C++17
0 / 100
7 ms 49244 KB
#include <bits/stdc++.h>
using namespace std;
long long dp[2501][2501],n,a,b,c;
string s;
int 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;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 49244 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 -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 49240 KB Output is correct
2 Incorrect 7 ms 49216 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 49244 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 -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 49244 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 -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 49244 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 -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 49244 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 -