Submission #932614

#TimeUsernameProblemLanguageResultExecution timeMemory
932614Ice_manSightseeing in Kyoto (JOI22_kyoto)C++14
10 / 100
6 ms8352 KiB
#include <iostream>
#include <chrono>

#define maxn 1005
#define maxlog 20
#define INF 1000000010
#define LINF 1000000000000000005
#define endl '\n'
#define pb(x) push_back(x)
#define X first
#define Y second
#define control cout<<"passed"<<endl;

#pragma GCC optimize("O3" , "Ofast" , "unroll-loops" , "fast-math")
#pragma GCC target("avx2")

using namespace std;

std::chrono::high_resolution_clock::time_point startT, currT;
constexpr double TIME_MULT = 1;

double timePassed()
{
    using namespace std::chrono;
    currT = high_resolution_clock::now();
    double time = duration_cast<duration<double>>(currT - startT).count();
    return time * TIME_MULT;
}


int n, m;

int a[maxn], b[maxn];
long long dp[maxn][maxn];

void read()
{
    cin >> n >> m;

    for(int i = 1; i <= n; i++)
        cin >> a[i];

    for(int i = 1; i <= m; i++)
        cin >> b[i];
}

void calc_dp()
{
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
        {
            if(i == 1 && j == 1)
            {
                dp[i][j] = 0;
                continue;
            }

            if(i == 1)
            {
                dp[i][j] = dp[i][j - 1] + a[i];
                continue;
            }

            if(j == 1)
            {
                dp[i][j] = dp[i - 1][j] + b[j];
                continue;
            }

            dp[i][j] = min(dp[i][j - 1] + a[i] , dp[i - 1][j] + b[j]);

        }

    cout << dp[n][m] << endl;
}




int main()
{

    /**#ifdef ONLINE_JUDGE
        freopen("taxi.in", "r", stdin);
        freopen("taxi.out", "w", stdout);
    #endif*/

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    startT = std::chrono::high_resolution_clock::now();

    read();
    calc_dp();


    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...