Submission #14257

# Submission time Handle Problem Language Result Execution time Memory
14257 2015-05-09T00:05:34 Z khsoo01 배열 탈출 (GA8_array) C++
100 / 100
560 ms 40528 KB
#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 time Memory Grader output
1 Correct 0 ms 40528 KB Output is correct
2 Correct 0 ms 40528 KB Output is correct
3 Correct 0 ms 40528 KB Output is correct
4 Correct 0 ms 40528 KB Output is correct
5 Correct 0 ms 40528 KB Output is correct
6 Correct 0 ms 40528 KB Output is correct
7 Correct 0 ms 40528 KB Output is correct
8 Correct 0 ms 40528 KB Output is correct
9 Correct 0 ms 40528 KB Output is correct
10 Correct 0 ms 40528 KB Output is correct
11 Correct 0 ms 40528 KB Output is correct
12 Correct 0 ms 40528 KB Output is correct
13 Correct 0 ms 40528 KB Output is correct
14 Correct 0 ms 40528 KB Output is correct
15 Correct 0 ms 40528 KB Output is correct
16 Correct 0 ms 40528 KB Output is correct
17 Correct 0 ms 40528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 40528 KB Output is correct
2 Correct 0 ms 40528 KB Output is correct
3 Correct 0 ms 40528 KB Output is correct
4 Correct 0 ms 40528 KB Output is correct
5 Correct 0 ms 40528 KB Output is correct
6 Correct 0 ms 40528 KB Output is correct
7 Correct 0 ms 40528 KB Output is correct
8 Correct 0 ms 40528 KB Output is correct
9 Correct 0 ms 40528 KB Output is correct
10 Correct 0 ms 40528 KB Output is correct
11 Correct 0 ms 40528 KB Output is correct
12 Correct 0 ms 40528 KB Output is correct
13 Correct 0 ms 40528 KB Output is correct
14 Correct 0 ms 40528 KB Output is correct
15 Correct 0 ms 40528 KB Output is correct
16 Correct 0 ms 40528 KB Output is correct
17 Correct 0 ms 40528 KB Output is correct
18 Correct 0 ms 40528 KB Output is correct
19 Correct 0 ms 40528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 40528 KB Output is correct
2 Correct 7 ms 40528 KB Output is correct
3 Correct 3 ms 40528 KB Output is correct
4 Correct 4 ms 40528 KB Output is correct
5 Correct 3 ms 40528 KB Output is correct
6 Correct 0 ms 40528 KB Output is correct
7 Correct 3 ms 40528 KB Output is correct
8 Correct 0 ms 40528 KB Output is correct
9 Correct 6 ms 40528 KB Output is correct
10 Correct 3 ms 40528 KB Output is correct
11 Correct 3 ms 40528 KB Output is correct
12 Correct 6 ms 40528 KB Output is correct
13 Correct 3 ms 40528 KB Output is correct
14 Correct 6 ms 40528 KB Output is correct
15 Correct 6 ms 40528 KB Output is correct
16 Correct 5 ms 40528 KB Output is correct
17 Correct 0 ms 40528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 547 ms 40528 KB Output is correct
2 Correct 529 ms 40528 KB Output is correct
3 Correct 479 ms 40528 KB Output is correct
4 Correct 560 ms 40528 KB Output is correct
5 Correct 414 ms 40528 KB Output is correct
6 Correct 492 ms 40528 KB Output is correct
7 Correct 545 ms 40528 KB Output is correct
8 Correct 551 ms 40528 KB Output is correct
9 Correct 551 ms 40528 KB Output is correct
10 Correct 473 ms 40528 KB Output is correct
11 Correct 396 ms 40528 KB Output is correct
12 Correct 457 ms 40528 KB Output is correct
13 Correct 398 ms 40528 KB Output is correct
14 Correct 417 ms 40528 KB Output is correct
15 Correct 344 ms 40528 KB Output is correct
16 Correct 406 ms 40528 KB Output is correct
17 Correct 355 ms 40528 KB Output is correct
18 Correct 415 ms 40528 KB Output is correct
19 Correct 474 ms 40528 KB Output is correct
20 Correct 390 ms 40528 KB Output is correct
21 Correct 398 ms 40528 KB Output is correct