Submission #567169

#TimeUsernameProblemLanguageResultExecution timeMemory
567169dantoh000Sightseeing in Kyoto (JOI22_kyoto)C++14
10 / 100
15 ms8312 KiB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000000000;
int n,m;
int a[1005], b[1005];
int mem[1005][1005];
int dp(int x, int y){
    if (x == n-1 && y == m-1) return 0;
    if (mem[x][y] != -1) return mem[x][y];
    int ret = INF;
    if (x != n-1) ret = min(ret, dp(x+1, y) + b[y]);
    if (y != m-1) ret = min(ret, dp(x, y+1) + a[x]);
    //printf("%lld %lld %lld %lld %lld\n",x,y,ret,a[x],b[y]);
    return mem[x][y] = ret;
}
main(){
    scanf("%lld%lld",&n,&m);
    for (int i = 0; i < n; i++){
        scanf("%lld",&a[i]);
    }
    for (int j = 0; j < m; j++){
        scanf("%lld",&b[j]);
    }
    memset(mem,-1,sizeof(mem));
    printf("%lld",dp(0,0));

}

Compilation message (stderr)

kyoto.cpp:17:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   17 | main(){
      | ^~~~
kyoto.cpp: In function 'int main()':
kyoto.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     scanf("%lld%lld",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
kyoto.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         scanf("%lld",&a[i]);
      |         ~~~~~^~~~~~~~~~~~~~
kyoto.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         scanf("%lld",&b[j]);
      |         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...