Submission #7840

#TimeUsernameProblemLanguageResultExecution timeMemory
7840comet배열 탈출 (GA8_array)C++98
100 / 100
1004 ms50072 KiB
#include<cstdio> #include<algorithm> #include<memory.h> #define INF 987654321 using namespace std; int n; int a[2500][2500]; int d[2500][2500]; int f(int x,int y){ if(x>=n||y>=n)return INF; if(x==n-1&&y==n-1)return 0; int& ret=d[x][y]; if(ret!=-1)return ret; ret=min(f(x+1,y)+max(a[x+1][y]-a[x][y]+1,0),f(x,y+1)+max(a[x][y+1]-a[x][y]+1,0)); return ret; } int main(){ scanf("%d",&n); memset(d,-1,sizeof(d)); for(int i=0;i<n;i++) for(int j=0;j<n;j++) scanf("%d",&a[i][j]); printf("%d",f(0,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...