2912021-07-18 20:27:42Szin AttilaDinamitcpp14Wrong answer 23/503ms2076 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void printq(priority_queue<ll> q)
{
  cout << "queue: ";
  while(!q.empty()){
    cout << q.top() << " ";
    q.pop();
  }
  cout << "\n";
}

int main() {
	ll n,m,k;
  cin >> n >> m >> k;

  vector<vector<ll> > tabla, dp(n+1, vector<ll>(m, 0));
  priority_queue<ll> mo;

  for(int i = 0; i < n; i++) {
    vector<ll> v;
    for(int j = 0; j < m; j++) {
      ll x;
      cin >> x;
      v.push_back(x);
    }
    tabla.push_back(v);
  }

  dp[0][0] = tabla[0][0];

  for(int i = 1; i < n; i++) {
    dp[i][0] = tabla[i][0] + dp[i-1][0];
  }
  for(int i = 1; i < m; i++) {
    dp[0][i] = tabla[0][i] + dp[0][i-1];
  }

  for(int i = 1; i < n; i++) {
    for(int j = 1; j < m; j++) {
      dp[i][j] = min(dp[i-1][j], dp[i][j-1]) + tabla[i][j];
    }
  }

  /*cout << "dp: " << "\n";
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < m; j++) {
      cout << dp[i][j] << " ";
    }
    cout << "\n";
  }*/

  ll i = n-1, j = m-1;
  while(i > 0 || j > 0)
  {
    //cout << "i: " << i << " j: " << j << " \n";
    mo.push(tabla[i][j]);
    if(i == 0) {
      j--;
    }
    else if(j == 0) {
      i--;
    }
    else {
      if(dp[i-1][j] < dp[i][j-1]) {
        i--;
      }
      else {
        j--;
      }
    }
  }
  mo.push(tabla[i][j]);

  //printq(mo);
  while(k--) {
    ll curr = mo.top();
    mo.pop();

    mo.push(curr/2);
  }
  //printq(mo);

  ll ki = 0;
  while(!mo.empty())
  {
    ki += mo.top();
    mo.pop();
  }
  cout << ki << "\n";
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base23/50
1Accepted0/02ms1740 KiB
2Wrong answer0/03ms1820 KiB
3Accepted2/22ms1892 KiB
4Accepted2/22ms1900 KiB
5Accepted3/32ms1912 KiB
6Accepted3/32ms1928 KiB
7Accepted2/22ms1944 KiB
8Accepted3/32ms1952 KiB
9Wrong answer0/22ms1944 KiB
10Accepted2/22ms1948 KiB
11Accepted3/31ms1952 KiB
12Wrong answer0/31ms1952 KiB
13Wrong answer0/22ms1972 KiB
14Accepted3/32ms1968 KiB
15Wrong answer0/22ms1996 KiB
16Wrong answer0/32ms2008 KiB
17Wrong answer0/22ms2024 KiB
18Wrong answer0/32ms2032 KiB
19Wrong answer0/22ms2040 KiB
20Wrong answer0/32ms2052 KiB
21Wrong answer0/22ms2072 KiB
22Wrong answer0/32ms2076 KiB