Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define fastio ios::sync_with_stdio(false),cin.tie(0);
- #define pll pair<ll,ll>
- #define F first
- #define S second
- #define pb push_back
- #define ppb pop_back()
- #define mkp make_pair
- #define sz(a) (ll)a.size()
- #define all(x) x.begin(),x.end()
- const ll MAXN=1001;
- const ll INF=1e18;
- const ll MOD=998244353;
- ll M,N,K;
- ll p[4],q[4];
- ll dp1[MAXN][MAXN],dp2[MAXN][MAXN];
- void init(){
- cin>>M>>N>>K;
- for(ll i=0;i<3;i++) cin>>p[i];
- for(ll i=0;i<3;i++) cin>>q[i];
- for(ll i=0;i<=M;i++){
- for(ll j=0;j<=N;j++){
- dp1[i][j]=dp2[i][j]=INF;
- }
- }
- dp1[0][0]=dp2[0][0]=0;
- for(ll i=0;i<=M;i++){
- for(ll j=0;j<=N;j++){
- if(i==0 && j==0) continue;
- if(i>0){
- dp1[i][j]=min(dp1[i][j],dp1[i-1][j]+p[0]);
- dp2[i][j]=min(dp2[i][j],dp2[i-1][j]+q[0]);
- }
- if(j>0){
- dp1[i][j]=min(dp1[i][j],dp1[i][j-1]+p[0]);
- dp2[i][j]=min(dp2[i][j],dp2[i][j-1]+q[0]);
- }
- if(j>0){
- dp1[i][j]=min(dp1[i][j],dp1[i][j-1]+p[1]);
- dp2[i][j]=min(dp2[i][j],dp2[i][j-1]+q[1]);
- }
- for(ll a=0;a<=5;a++){//ๅคงไบบ
- for(ll c=0;c<=2*(5-a);c++){
- if(i>=a && j>=c){
- dp1[i][j]=min(dp1[i][j],dp1[i-a][j-c]+p[2]);
- dp2[i][j]=min(dp2[i][j],dp2[i-a][j-c]+q[2]);
- }
- }
- }
- }
- }
- ll ans=INF;
- for(ll i=0;i<=M;i++){
- for(ll j=0;j<=N;j++){
- ans=min(ans,dp1[i][j]*K+dp2[M-i][N-j]);
- }
- }
- cout<<ans<<"\n";
- }
- void solve(){
- }
- signed main(){
- fastio
- freopen("munich.in","r",stdin);
- freopen("munich.out","w",stdout);
- // ll T;
- // cin>>T;
- // while(T--){
- init();
- solve();
- // }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement