답안 #7850

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
7850 2014-08-20T05:14:25 Z ainu7 배열 탈출 (GA8_array) C++
100 / 100
668 ms 43836 KB
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;

int a[2323][2323];
int cost[2323][2323];

int from(int b, int c) {
  return max(0, c-b+1);
}

int main()
{
  int n;
  scanf("%d", &n);
  for (int i=0; i<n; i++)
    for (int j=0; j<n; j++)
      scanf("%d", &a[i][j]);

  for (int i=0; i<n; i++)
    for (int j=0; j<n; j++) {
      if (i == 0 && j == 0) { cost[i][j] = 0; continue; }
      cost[i][j] = 999999999;
      if (i) cost[i][j] = min(cost[i][j], cost[i-1][j] + from(a[i-1][j], a[i][j]));
      if (j) cost[i][j] = min(cost[i][j], cost[i][j-1] + from(a[i][j-1], a[i][j]));
    }
  printf("%d\n", cost[n-1][n-1]);

}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 43836 KB Output is correct
2 Correct 0 ms 43836 KB Output is correct
3 Correct 0 ms 43836 KB Output is correct
4 Correct 0 ms 43836 KB Output is correct
5 Correct 0 ms 43836 KB Output is correct
6 Correct 0 ms 43836 KB Output is correct
7 Correct 0 ms 43836 KB Output is correct
8 Correct 0 ms 43836 KB Output is correct
9 Correct 0 ms 43836 KB Output is correct
10 Correct 0 ms 43836 KB Output is correct
11 Correct 0 ms 43836 KB Output is correct
12 Correct 0 ms 43836 KB Output is correct
13 Correct 0 ms 43836 KB Output is correct
14 Correct 0 ms 43836 KB Output is correct
15 Correct 0 ms 43836 KB Output is correct
16 Correct 0 ms 43836 KB Output is correct
17 Correct 0 ms 43836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 43836 KB Output is correct
2 Correct 0 ms 43836 KB Output is correct
3 Correct 0 ms 43836 KB Output is correct
4 Correct 0 ms 43836 KB Output is correct
5 Correct 0 ms 43836 KB Output is correct
6 Correct 0 ms 43836 KB Output is correct
7 Correct 0 ms 43836 KB Output is correct
8 Correct 0 ms 43836 KB Output is correct
9 Correct 0 ms 43836 KB Output is correct
10 Correct 0 ms 43836 KB Output is correct
11 Correct 0 ms 43836 KB Output is correct
12 Correct 0 ms 43836 KB Output is correct
13 Correct 0 ms 43836 KB Output is correct
14 Correct 0 ms 43836 KB Output is correct
15 Correct 0 ms 43836 KB Output is correct
16 Correct 0 ms 43836 KB Output is correct
17 Correct 0 ms 43836 KB Output is correct
18 Correct 0 ms 43836 KB Output is correct
19 Correct 0 ms 43836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 43836 KB Output is correct
2 Correct 8 ms 43836 KB Output is correct
3 Correct 8 ms 43836 KB Output is correct
4 Correct 8 ms 43836 KB Output is correct
5 Correct 8 ms 43836 KB Output is correct
6 Correct 8 ms 43836 KB Output is correct
7 Correct 8 ms 43836 KB Output is correct
8 Correct 0 ms 43836 KB Output is correct
9 Correct 8 ms 43836 KB Output is correct
10 Correct 4 ms 43836 KB Output is correct
11 Correct 8 ms 43836 KB Output is correct
12 Correct 8 ms 43836 KB Output is correct
13 Correct 4 ms 43836 KB Output is correct
14 Correct 8 ms 43836 KB Output is correct
15 Correct 8 ms 43836 KB Output is correct
16 Correct 8 ms 43836 KB Output is correct
17 Correct 8 ms 43836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 616 ms 43836 KB Output is correct
2 Correct 644 ms 43836 KB Output is correct
3 Correct 620 ms 43836 KB Output is correct
4 Correct 620 ms 43836 KB Output is correct
5 Correct 524 ms 43836 KB Output is correct
6 Correct 592 ms 43836 KB Output is correct
7 Correct 616 ms 43836 KB Output is correct
8 Correct 624 ms 43836 KB Output is correct
9 Correct 668 ms 43836 KB Output is correct
10 Correct 608 ms 43836 KB Output is correct
11 Correct 604 ms 43836 KB Output is correct
12 Correct 592 ms 43836 KB Output is correct
13 Correct 524 ms 43836 KB Output is correct
14 Correct 576 ms 43836 KB Output is correct
15 Correct 480 ms 43836 KB Output is correct
16 Correct 588 ms 43836 KB Output is correct
17 Correct 612 ms 43836 KB Output is correct
18 Correct 568 ms 43836 KB Output is correct
19 Correct 628 ms 43836 KB Output is correct
20 Correct 632 ms 43836 KB Output is correct
21 Correct 564 ms 43836 KB Output is correct