Submission #602592

#TimeUsernameProblemLanguageResultExecution timeMemory
602592CyberCowSightseeing in Kyoto (JOI22_kyoto)C++17
10 / 100
9 ms8208 KiB
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <fstream>
#include <iomanip>
#include <iterator>
#include <stack>
#include <deque>
using namespace std;
using ll = long long;
ll dp[1005][1005];
vector<ll> a, b;

void solve()
{
	ll n, i, j, x, y, h, w;
	cin >> h >> w;
	for ( i = 0; i < h; i++)
	{
		cin >> x;
		a.push_back(x);
	}
	for ( i = 0; i < w; i++)
	{
		cin >> x;
		b.push_back(x);
	}
	for ( i = 0; i < h; i++)
	{
		dp[i][0] = i * b[0];
	}
	for ( i = 0; i < w; i++)
	{
		dp[0][i] = i * a[0];
	}
	for ( i = 1; i < h; i++)
	{
		for ( j = 1; j < w; j++)
		{
			dp[i][j] = min(dp[i - 1][j] + b[j], dp[i][j - 1] + a[i]);
		}
	}
	cout << dp[h - 1][w - 1];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tt = 1;
	//cin >> tt;
	while (tt--)
	{
		solve();
	}
	return 0;
}

Compilation message (stderr)

kyoto.cpp: In function 'void solve()':
kyoto.cpp:23:5: warning: unused variable 'n' [-Wunused-variable]
   23 |  ll n, i, j, x, y, h, w;
      |     ^
kyoto.cpp:23:17: warning: unused variable 'y' [-Wunused-variable]
   23 |  ll n, i, j, x, y, h, w;
      |                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...