89652024-02-08 07:17:21BenedekMartonDinamitcpp17Wrong answer 23/503ms4552 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    long long ert[n][m], ost[n][m];
    bool elt[n][m];
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            cin >> ert[i][j];
        }
    }
    ost[0][0]=ert[0][0];
    for(int i=1; i<n; i++)
    {
        ost[i][0]=ert[i][0]+ost[i-1][0];
        elt[i][0]=1;
    }
    for(int i=1; i<m; i++)
    {
        ost[0][i]=ert[0][i]+ost[0][i-1];
        elt[0][i]=0;
    }
    for(int i=1; i<n; i++)
    {
        for(int j=1; j<m; j++)
        {
            if(ost[i-1][j]<ost[i][j-1])
            {
                ost[i][j]=ert[i][j]+ost[i-1][j];
                elt[i][j]=1;
            }
            else
            {
                ost[i][j]=ert[i][j]+ost[i][j-1];
                elt[i][j]=0;
            }
        }
    }
    vector <int> ut;
    int i=n-1, j=m-1;
    while(!(i==0 and j==0))
    {
        ut.push_back(ert[i][j]);
        if(elt[i][j])
        {
            i--;
        }
        else
        {
            j--;
        }
    }
    ut.push_back(ert[0][0]);
    int mi;
    long long ossz=0;
    while(k>0)
    {
        mi=0;
        for(i=1; i<n+m-1; i++)
        {
            //cout << ut[i] << " ";
            if(ut[mi]<ut[i])
            {
                mi=i;
            }
        }
        //cout << endl;
        ut[mi]=ut[mi]/2;
        k--;
    }
    for(int i=0; i<n+m-1; i++)
    {
        ossz=ossz+ut[i];
    }
    cout << ossz;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base23/50
1Accepted0/03ms1808 KiB
2Wrong answer0/03ms2084 KiB
3Accepted2/23ms2292 KiB
4Accepted2/23ms2448 KiB
5Accepted3/33ms2552 KiB
6Accepted3/33ms2644 KiB
7Accepted2/23ms2776 KiB
8Accepted3/33ms2976 KiB
9Wrong answer0/23ms3032 KiB
10Accepted2/23ms3160 KiB
11Accepted3/33ms3376 KiB
12Wrong answer0/33ms3460 KiB
13Wrong answer0/23ms3592 KiB
14Accepted3/33ms3704 KiB
15Wrong answer0/23ms3824 KiB
16Wrong answer0/33ms3908 KiB
17Wrong answer0/23ms4124 KiB
18Wrong answer0/33ms4248 KiB
19Wrong answer0/23ms4332 KiB
20Wrong answer0/33ms4552 KiB
21Wrong answer0/23ms4544 KiB
22Wrong answer0/33ms4548 KiB