46082023-03-30 11:35:28csaron71Dinamitcpp17Wrong answer 18/503ms4432 KiB
#include <bits/stdc++.h>

using namespace std;



int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<int> > ert(n, vector<int>(m));

    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            cin >> ert[i][j];
        }
    }

    vector<vector<int> > dp(n, vector<int>(m, INT_MAX));
    dp[0][0]=ert[0][0];
    for (int j=m-1; j>=0; j--) {
        for (int i=n-1; i>=0; i--) {
            if (i!=n-1) {
                dp[i][j]=min(dp[i][j], dp[i+1][j]+ert[i][j]);
            }
            if (j!=m-1) {
                dp[i][j]=min(dp[i][j], dp[i][j+1]+ert[i][j]);
            }
        }
    }
    /*cout << "\n";
    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            cout << dp[i][j] << " ";
        }
        cout << "\n";
    }*/

    vector<int> visszafejt;
    int x=0, y=0;
    visszafejt.push_back(ert[0][0]);
    //cout << "\n";
    while (x<n && y<m) {
        //cout << x << " " << y << "\n";
        if (x<n-1 && dp[x][y]==dp[x+1][y]+ert[x][y]) {
            x++;
        }
        else {
            y++;
        }
        visszafejt.push_back(ert[x][y]);
    }
    for (int i=0; i<k; i++) {
        int maxi=0, hely=0;
        for (int j=0; j<visszafejt.size(); j++) {
            if (maxi<visszafejt[j]) {
                maxi=visszafejt[j];
                hely=j;
            }
        }
        visszafejt[hely]/=2;
        /*for (int j=0; j<visszafejt.size(); j++) {
            cout << visszafejt[j] << " ";
        }
        cout << "\n";*/
    }

    int veg=0;
    for (int j=0; j<visszafejt.size(); j++) {
        veg+=visszafejt[j];
        //cout << visszafejt[j] << " ";
    }
    cout << veg << endl;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base18/50
1Accepted0/03ms1684 KiB
2Wrong answer0/03ms1948 KiB
3Accepted2/23ms2076 KiB
4Accepted2/23ms2284 KiB
5Accepted3/33ms2496 KiB
6Accepted3/33ms2708 KiB
7Accepted2/23ms2920 KiB
8Accepted3/33ms3132 KiB
9Wrong answer0/23ms3480 KiB
10Wrong answer0/23ms3524 KiB
11Wrong answer0/33ms3668 KiB
12Wrong answer0/32ms3684 KiB
13Wrong answer0/23ms3676 KiB
14Accepted3/33ms3712 KiB
15Wrong answer0/23ms3636 KiB
16Wrong answer0/33ms3716 KiB
17Wrong answer0/23ms3928 KiB
18Wrong answer0/33ms4140 KiB
19Wrong answer0/23ms4224 KiB
20Wrong answer0/33ms4228 KiB
21Wrong answer0/23ms4348 KiB
22Wrong answer0/33ms4432 KiB