Submission #56358

#TimeUsernameProblemLanguageResultExecution timeMemory
56358leejseo배열 탈출 (GA8_array)C++98
49 / 100
971 ms66560 KiB
#include <stdio.h> #include <algorithm> using namespace std; int A[2230][2230], D[2230][2230], N; inline bool valid(int i, int j) { return 0<=i && i<N && 0<=j && j<N; } void input(){ scanf("%d", &N); for (int i=0; i<N; i++){ for (int j=0; j<N; j++){ scanf("%d", &A[i][j]); } } } void DP(){ D[0][0] = 0; for (int i=0; i<N; i++){ for (int j=0; j<N; j++){ if (i == 0 && j == 0) continue; D[i][j] = (int)1e9; if (valid(i-1, j)) D[i][j] = min(D[i][j], D[i-1][j] + max(0, A[i][j] - A[i-1][j] + 1)); if (valid(i, j-1)) D[i][j] = min(D[i][j], D[i][j-1] + max(0, A[i][j] - A[i][j-1] + 1)); } } } int main(void){ input(); DP(); printf("%d\n", D[N-1][N-1]); }

Compilation message (stderr)

array.cpp: In function 'void input()':
array.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
array.cpp:14:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &A[i][j]);
    ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...