Submission #14257

#TimeUsernameProblemLanguageResultExecution timeMemory
14257khsoo01배열 탈출 (GA8_array)C++98
100 / 100
560 ms40528 KiB
#include<iostream> #include<algorithm> using namespace std; #define INF 987654321 int i,j,n,d[2229][2229],a[2229][2229]; int main() { std::cin.sync_with_stdio(false); cin>>n; for(;i++<n;d[i][0]=INF)for(j=0;j++<n;)cin>>a[i][j]; d[0][0]=INF; for(i=1;i<=n;i++)d[0][i]=INF; for(j=2;j<=n;j++) { d[1][j]=min(d[0][j]+(a[1][j]<a[0][j]?0:a[1][j]-a[0][j]+1) ,d[1][j-1]+(a[1][j]<a[1][j-1]?0:a[1][j]-a[1][j-1]+1)); } for(i=2;i<=n;i++) { for(j=1;j<=n;j++) { d[i][j]=min(d[i-1][j]+(a[i][j]<a[i-1][j]?0:a[i][j]-a[i-1][j]+1) ,d[i][j-1]+(a[i][j]<a[i][j-1]?0:a[i][j]-a[i][j-1]+1)); } } cout<<d[n][n]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...