93842024-02-21 11:30:28ananászDinamitcpp17Wrong answer 23/503ms4560 KiB
// dinamit.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
	int N, M, K;
	cin >> N >> M >> K;
	vector<vector<int>>sum(N, vector<int>(M, 0));
	vector<vector<int>>faradtsag(N, vector<int>(M, 0));
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++)
		{
			cin >> faradtsag[i][j];
		}
	}
	sum[0][0] = faradtsag[0][0];
	for (int i = 1; i < M; i++)
	{
		sum[0][i] = sum[0][i - 1] + faradtsag[0][i];
	}
	for (int i = 1; i < N; i++)
	{
		for (int j = 0; j < M; j++)
		{
			if (j == 0)
			{
				sum[i][j] = sum[i - 1][0] + faradtsag[i][j];
			}
			else
			{
				sum[i][j] = min(sum[i - 1][j], sum[i][j - 1]) + faradtsag[i][j];
			}

		}
	}
	int ertek= sum[N-1][M-1];
	priority_queue<int>robbantas;
	pair<int, int>akt;
	robbantas.push(faradtsag[N - 1][M - 1]);
	akt.first = N - 1;
	akt.second = M - 1;
	while (akt.first>0&&akt.second>0)
	{
		if (sum[akt.first-1][akt.second]<sum[akt.first][akt.second-1])
		{
			akt.first--;
		}
		else
		{
			akt.second--;
		}
		robbantas.push(faradtsag[akt.first][akt.second]);
	}
	while (akt.first>0)
	{
		akt.first--;
		robbantas.push(faradtsag[akt.first][akt.second]);
	}
	while (akt.second>0)
	{
		akt.second--;
		robbantas.push(faradtsag[akt.first][akt.second]);
	}
	int x;
	int y;
	for (int i = 0; i < K; i++)
	{
		x=robbantas.top();
		robbantas.pop();
		if (x%2==0)
		{
			x = x / 2;
			y = x;
		}
		else
		{
			x = x / 2;
			y=x+1;
		}
		ertek -= y;
		robbantas.push(x);
	}
	cout << ertek << endl;
	return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base23/50
1Accepted0/03ms1816 KiB
2Wrong answer0/03ms2068 KiB
3Accepted2/23ms2296 KiB
4Accepted2/23ms2440 KiB
5Accepted3/33ms2672 KiB
6Accepted3/33ms2760 KiB
7Accepted2/23ms3244 KiB
8Accepted3/33ms3236 KiB
9Wrong answer0/23ms3428 KiB
10Accepted2/23ms3548 KiB
11Accepted3/33ms3764 KiB
12Wrong answer0/33ms3976 KiB
13Wrong answer0/23ms4060 KiB
14Accepted3/33ms4180 KiB
15Wrong answer0/23ms4196 KiB
16Wrong answer0/33ms4172 KiB
17Wrong answer0/23ms4304 KiB
18Wrong answer0/33ms4488 KiB
19Wrong answer0/23ms4560 KiB
20Wrong answer0/33ms4448 KiB
21Wrong answer0/23ms4544 KiB
22Wrong answer0/33ms4448 KiB