# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
56356 | leejseo | 배열 탈출 (GA8_array) | C++98 | 952 ms | 66560 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
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 s=1; s<2*N-1; s++){
for (int i=max(0, s-N+1); i<min(N, s+1); i++){
int j = s-i;
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]);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |