Submission #56376

#TimeUsernameProblemLanguageResultExecution timeMemory
56376leejseo배열 탈출 (GA8_array)C++98
49 / 100
804 ms66560 KiB
#include <stdio.h> #include <algorithm> #define INF 1000000000 using namespace std; int C[2223], B[2223], CUR[2223], BF[2223], N; void input(){ scanf("%d", &N); } void DP(){ for (int i=0; i<=N; i++){ BF[i] = INF; } for (int i=1; i<=N; i++){ CUR[0] = INF; for (int j=1; j<=N; j++){ B[j] = C[j]; scanf("%d", &C[j]); if (i + j == 2){ CUR[1] = 0; BF[1] = 0; continue; } CUR[j] = min(BF[j] + (B[j] > C[j]? 0 : C[j] - B[j] + 1), CUR[j-1] + (C[j-1] > C[j]? 0 : C[j] - C[j-1] + 1)); BF[j] = CUR[j]; } } } int main(void){ input(); DP(); printf("%d\n", CUR[N]); }

Compilation message (stderr)

array.cpp: In function 'void input()':
array.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
array.cpp: In function 'void DP()':
array.cpp:19:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &C[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...