Advertisement
YEZAELP

PROG-1114: กระโดดสูง (HighJ)

Oct 16th, 2021
711
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. const int INF = 1e9;
  5. const int N = 610;
  6. int ar[N][N], dp[N];
  7.  
  8. int main(){
  9.  
  10.     int n, nn;
  11.     scanf("%d", &n);
  12.     nn = 2 * n;
  13.  
  14.     for(int i=1;i<=nn;i++){
  15.         dp[i] = INF;
  16.         for(int j=1;j<=nn;j++){
  17.             scanf("%d", &ar[i][j]);
  18.         }
  19.     }
  20.  
  21.     dp[2] = 0; /// [1][1]
  22.     for(int i=1;i<=nn;i++){
  23.         for(int j=1;j<i;j++){
  24.             dp[i] = min(dp[i], ar[i][j] + dp[j]);
  25.         }
  26.     }
  27.  
  28.     printf("%d", dp[nn]);
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement