46752023-03-30 20:46:31Erik_GepardDinamitcpp17Wrong answer 23/503ms4140 KiB
#include <bits/stdc++.h>
using namespace std;

#define pii pair<int, int>
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define int long long

void solve(){
    int n, m, d;
    cin>>n>>m>>d;
    vector<vector<int>> dp(n+1, vector<int>(m+1));
    vector<vector<int>> from(n+1, vector<int>(m+1)); //1 fentről i-1, 2 balról j-1
    vector<vector<int>> p(n+1, vector<int>(m+1));
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            cin>>p[i][j];
        }
    }
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            if(i==1 && j==1){
                dp[i][j]=p[i][j];
            }
            else if(i==1){
                dp[i][j]=dp[i][j-1]+p[i][j];
                from[i][j]=2;
            }
            else if(j==1){
                dp[i][j]=dp[i-1][j]+p[i][j];
                from[i][j]=1;
            }
            else{
                if(dp[i-1][j]<dp[i][j-1]){
                    dp[i][j]=dp[i-1][j]+p[i][j];
                    from[i][j]=1;
                }
                else{
                    dp[i][j]=dp[i][j-1]+p[i][j];
                    from[i][j]=2;
                }
            }
        }
    }
    pii most={n, m};
    priority_queue<int> ans;
    while(most.fi>0 && most.se>0){
        ans.push(p[most.fi][most.se]);
        if(from[most.fi][most.se]==1){
            most.fi--;
        }
        else if(from[most.fi][most.se]==2){
            most.se--;
        }
        else break;
    }
    for(int i=0; i<d; i++){
        int x=ans.top();
        ans.pop();
        x/=2;
        ans.push(x);
    }
    int vege=0;
    while(!ans.empty()){
        vege+=ans.top();
        ans.pop();
    }
    cout<<vege<<"\n";
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
}
SubtaskSumTestVerdictTimeMemory
base23/50
1Accepted0/03ms1828 KiB
2Wrong answer0/03ms2236 KiB
3Accepted2/23ms2452 KiB
4Accepted2/23ms2588 KiB
5Accepted3/33ms2800 KiB
6Accepted3/33ms3008 KiB
7Accepted2/23ms3096 KiB
8Accepted3/33ms3160 KiB
9Wrong answer0/23ms3176 KiB
10Accepted2/22ms3176 KiB
11Accepted3/32ms3176 KiB
12Wrong answer0/32ms3184 KiB
13Wrong answer0/23ms3404 KiB
14Accepted3/32ms3488 KiB
15Wrong answer0/23ms3780 KiB
16Wrong answer0/33ms3736 KiB
17Wrong answer0/23ms3736 KiB
18Wrong answer0/33ms3856 KiB
19Wrong answer0/23ms3808 KiB
20Wrong answer0/33ms3952 KiB
21Wrong answer0/23ms4140 KiB
22Wrong answer0/33ms4096 KiB