8482022-01-20 15:28:54Halasz EszterDinamitcpp11Wrong answer 20/503ms2184 KiB
#include <iostream>
//#include <fstream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;

//ifstream cin("dinamit.in");
//ofstream cout("dinamit.out");

vector<ll>v;

ll n,m,i,j,x[101][101],y[101][101],d,db;

void leker(ll i,ll j)
{
    if(i!=1 || j!=1)
    {
        if(y[i-1][j]<y[i][j-1]) leker(i-1,j);
        else leker(i,j-1);
    }
    v.push_back(x[i][j]);
}
ll has(ll a,ll b)
{
    if(a<b) return 0;
    else return 1;
}
int main()
{
    cin>>n>>m>>d;
    for(i=1;i<=n;++i)
        for(j=1;j<=m;++j) cin>>x[i][j];



    for(i=1;i<=m;++i) y[1][i]=y[1][i-1]+x[1][i];
    for(i=1;i<=n;++i) y[i][1]=y[i-1][1]+x[i][1];
    for(i=2;i<=n;++i)
    {
        for(j=2;j<=m;++j)
                y[i][j]=x[i][j]+min(y[i-1][j],y[i][j-1]);
    }

     for(i=0;i<=m;++i) y[0][i]=99999999;
    for(i=0;i<=n;++i) y[i][0]=99999999;
    
    leker(n,m);



    sort(v.begin(),v.end(),has);

     //for(auto e:v) cout<<e<<"\n";

    while(d>0)
    {
        v[0]=v[0]/2;
        if(v[0]<v[1])
    sort(v.begin(),v.end(),has);
        d--;
    }
    db=0;
    for(auto e:v) db+=e;
    cout<<db;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base20/50
1Accepted0/02ms1820 KiB
2Wrong answer0/02ms2052 KiB
3Accepted2/22ms2000 KiB
4Accepted2/23ms2016 KiB
5Accepted3/32ms2020 KiB
6Accepted3/33ms2040 KiB
7Accepted2/22ms2048 KiB
8Runtime error0/33ms2172 KiB
9Wrong answer0/22ms2028 KiB
10Accepted2/22ms2028 KiB
11Accepted3/31ms2032 KiB
12Wrong answer0/31ms2048 KiB
13Wrong answer0/21ms2064 KiB
14Accepted3/31ms2064 KiB
15Wrong answer0/22ms2112 KiB
16Wrong answer0/32ms2120 KiB
17Wrong answer0/22ms2124 KiB
18Wrong answer0/31ms2140 KiB
19Wrong answer0/22ms2152 KiB
20Wrong answer0/33ms2160 KiB
21Wrong answer0/22ms2176 KiB
22Wrong answer0/32ms2184 KiB