238522026-01-30 21:19:13sarminDinamitcpp17Wrong answer 23/502ms760 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// const ll MOD = 1e9+7;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define int long long

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m, k; cin >> n >> m >> k;
    vector<vector<int>> a(n+1, vector<int>(m+1)), dp(n+1, vector<int>(m+1, 0));
    for (int i = 1; i <= n; i++) {
    	for (int j = 1; j <= m; j++) {
    		cin >> a[i][j];
    	}
    }
    
    
    for (int i = 0; i <= n; i++) {
    	dp[i][0] = INT_MAX;
    	dp[0][i] = INT_MAX;
    }
    dp[1][1] = a[1][1];
    for (int i = 1; i <= n; i++) {
    	for (int j = 1; j <= m; j++) {
    		if (i == 1 && j == 1) continue;
    		dp[i][j] = min(dp[i-1][j], dp[i][j-1]) + a[i][j];
    	}
    }
    
    priority_queue<int> q;
    int i = n, j = n;
    ll ans = 0;
    while (i >= 1 && j >= 1) {
    	q.push(a[i][j]);
    	ans += a[i][j];
    	if (dp[i-1][j] > dp[i][j-1]) {
    		j--;
    	} else {
    		i--;
    	}
    }
    // cerr << ans << "\n";
    while (k--) {
    	int top = q.top();
    	q.pop();
    	ans -= top;
    	q.push(top/2);
    	ans += top/2;
    }
    
    cout << ans;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base23/50
1Accepted0/01ms500 KiB
2Wrong answer0/01ms316 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms436 KiB
5Accepted3/31ms316 KiB
6Accepted3/31ms316 KiB
7Accepted2/21ms316 KiB
8Accepted3/31ms316 KiB
9Wrong answer0/21ms316 KiB
10Accepted2/21ms316 KiB
11Accepted3/31ms508 KiB
12Wrong answer0/31ms316 KiB
13Wrong answer0/21ms324 KiB
14Accepted3/31ms760 KiB
15Wrong answer0/21ms380 KiB
16Wrong answer0/31ms316 KiB
17Wrong answer0/21ms316 KiB
18Wrong answer0/31ms316 KiB
19Wrong answer0/22ms528 KiB
20Wrong answer0/31ms316 KiB
21Wrong answer0/21ms316 KiB
22Wrong answer0/31ms316 KiB