답안 #836032

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
836032 2023-08-24T05:37:39 Z veehj Sightseeing in Kyoto (JOI22_kyoto) C++17
10 / 100
455 ms 1048576 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define sz(a) (int)a.size()
#define all(x) (x).begin(), (x).end()
vector<vector<ll>> v;
ll h, w; vector<ll> x, y;

ll f(ll a, ll b){
  if(a<0 || a>=h || b<0 || b>=w) return -1;
  return v[a][b];
}

int main() {
  cin >> h >> w;
  x.resize(h); y.resize(w);
  for(auto& u : x) cin >> u; 
  for(auto& u : y) cin >> u;
  v.assign(h+1, vector<ll>(w+1, -1));
  v[0][0]=0;
  for(ll i=0; i<h; i++){
    for(ll j=0; j<w; j++){
      if(i==0 && j==0) continue;
      ll a=f(i-1, j), b=f(i, j-1);
      if(a==-1) v[i][j]=b+x[i];
      else if(b==-1) v[i][j]=a+y[j];
      else v[i][j]=min(a+y[j], b+x[i]);
    }
  }
  cout << v[h-1][w-1] << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 724 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 7 ms 8148 KB Output is correct
10 Correct 7 ms 8144 KB Output is correct
11 Correct 7 ms 8148 KB Output is correct
12 Correct 7 ms 8124 KB Output is correct
13 Correct 7 ms 8148 KB Output is correct
14 Correct 8 ms 8216 KB Output is correct
15 Correct 7 ms 8148 KB Output is correct
16 Correct 7 ms 8148 KB Output is correct
17 Correct 9 ms 8148 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 296 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 4 ms 3412 KB Output is correct
4 Runtime error 455 ms 1048576 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 724 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 7 ms 8148 KB Output is correct
10 Correct 7 ms 8144 KB Output is correct
11 Correct 7 ms 8148 KB Output is correct
12 Correct 7 ms 8124 KB Output is correct
13 Correct 7 ms 8148 KB Output is correct
14 Correct 8 ms 8216 KB Output is correct
15 Correct 7 ms 8148 KB Output is correct
16 Correct 7 ms 8148 KB Output is correct
17 Correct 9 ms 8148 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 296 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 4 ms 3412 KB Output is correct
32 Runtime error 455 ms 1048576 KB Execution killed with signal 9
33 Halted 0 ms 0 KB -