Submission #7424

#TimeUsernameProblemLanguageResultExecution timeMemory
7424mrcamel배열 탈출 (GA8_array)C++98
100 / 100
636 ms39692 KiB
#include <cstdio> using namespace std; #define in cin #define out cout struct RR { int w, cost; }; RR room[2223][2223]; int main() { int n; scanf("%d", &n); for(int i=1; i<=n; i++) { for(int j=1; j<=n; j++) { scanf("%d", &room[i][j].w); room[i][j].cost = 0; } } for(int i=0; i<=n; i++) { room[0][i].w = 300; room[i][0].w = 300; } // for(int i=2; i<=n; i++) { if(room[1][i-1].w <= room[1][i].w) room[1][i].cost = room[1][i].w - room[1][i-1].w + 1; if(room[i-1][1].w <= room[i][1].w) room[i][1].cost = room[i][1].w - room[i-1][1].w + 1; room[1][i].cost += room[1][i-1].cost; room[i][1].cost += room[i-1][1].cost; } for(int i=2; i<=n; i++) { for(int j=2; j<=n; j++) { RR &r0 = room[i][j]; RR &r1 = room[i-1][j]; RR &r2 = room[i][j-1]; int r1c = 0; int r2c = 0; if(r0.w >= r1.w) r1c = r0.w - r1.w + 1; r1c += r1.cost; if(r0.w >= r2.w) r2c = r0.w - r2.w + 1; r2c += r2.cost; if(r1c < r2c) r0.cost = r1c; else r0.cost = r2c; } } printf("%d", room[n][n].cost); 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...