Submission #7191

#TimeUsernameProblemLanguageResultExecution timeMemory
7191tncks0121배열 탈출 (GA8_array)C++98
100 / 100
660 ms40008 KiB
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 
#include <memory.h> 
#include <math.h> 
#include <assert.h> 
#include <stack> 
#include <queue> 
#include <map> 
#include <set> 
#include <algorithm> 
#include <string> 
#include <functional> 
#include <vector> 
#include <deque> 
#include <utility> 
#include <bitset> 
#include <limits.h>  

using namespace std; 
typedef long long ll; 
typedef unsigned long long llu; 
typedef double lf;
typedef unsigned int uint;
typedef long double llf;
typedef pair<int, int> pii;

const int SZ = 2222;

int N;
int A[SZ+10][SZ+10];
int Table[SZ+10][SZ+10];

int main() {
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) for(int j = 1; j <= N; j++) scanf("%d", &A[i][j]), Table[i][j] = (int)1e9;

	Table[1][1] = 0;
	for(int i = 1; i <= N; i++) for(int j = 1; j <= N; j++) {
		if(i+1 <= N) Table[i+1][j] = min(Table[i+1][j], Table[i][j] + max(A[i+1][j] - A[i][j] + 1, 0));
		if(j+1 <= N) Table[i][j+1] = min(Table[i][j+1], Table[i][j] + max(A[i][j+1] - A[i][j] + 1, 0));
	}

	printf("%d\n", Table[N][N]);
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...