답안 #42470

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
42470 2018-02-27T14:46:25 Z sinhriv 도장 모으기 (JOI14_stamps) C++14
100 / 100
128 ms 36652 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 3030;

int n, T;
int f[N][N]; 
bool minimize(int &u, int v){
  if(u > v){
    u = v;
    return 1;
  }
  return 0;
}

int main(){

  scanf("%d%d", &n, &T);

  memset(f, 60, sizeof f);

  f[0][0] = T;

  for(int i = 0; i < n; ++i){
    int U, V, D, E;
    cin >> U >> V >> D >> E;


    for(int j = 0; j <= n; ++j){
      if(f[i][j] == f[n + 2][1]) continue;

      f[i + 1][j] = min(f[i + 1][j], f[i][j] + U + V + T * (j * 2 + 1));

      f[i + 1][j + 1] = min(f[i + 1][j + 1], f[i][j] + V + D + T * (j * 2 + 1));

      if(j > 0){
        f[i + 1][j] = min(f[i + 1][j], f[i][j] + E + D + T * (j * 2 + 1));
        f[i + 1][j - 1] = min(f[i + 1][j - 1], f[i][j] + U + E + T * (j * 2 + 1));
      }
    }

    for(int j = 1; j <= n; ++j) f[i + 1][j] = min(f[i + 1][j - 1] + V + D, f[i + 1][j]);
  }

  cout << f[n][0];

	return 0;
}

Compilation message

stamps.cpp: In function 'int main()':
stamps.cpp:19:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &n, &T);
                        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 36216 KB Output is correct
2 Correct 28 ms 36320 KB Output is correct
3 Correct 27 ms 36500 KB Output is correct
4 Correct 32 ms 36500 KB Output is correct
5 Correct 32 ms 36500 KB Output is correct
6 Correct 26 ms 36524 KB Output is correct
7 Correct 27 ms 36524 KB Output is correct
8 Correct 28 ms 36524 KB Output is correct
9 Correct 26 ms 36524 KB Output is correct
10 Correct 26 ms 36524 KB Output is correct
11 Correct 27 ms 36524 KB Output is correct
12 Correct 30 ms 36572 KB Output is correct
13 Correct 27 ms 36572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 36572 KB Output is correct
2 Correct 27 ms 36572 KB Output is correct
3 Correct 29 ms 36572 KB Output is correct
4 Correct 26 ms 36572 KB Output is correct
5 Correct 26 ms 36572 KB Output is correct
6 Correct 28 ms 36572 KB Output is correct
7 Correct 26 ms 36572 KB Output is correct
8 Correct 28 ms 36572 KB Output is correct
9 Correct 27 ms 36572 KB Output is correct
10 Correct 26 ms 36572 KB Output is correct
11 Correct 28 ms 36572 KB Output is correct
12 Correct 27 ms 36572 KB Output is correct
13 Correct 26 ms 36572 KB Output is correct
14 Correct 28 ms 36572 KB Output is correct
15 Correct 27 ms 36588 KB Output is correct
16 Correct 27 ms 36588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 113 ms 36588 KB Output is correct
2 Correct 28 ms 36588 KB Output is correct
3 Correct 111 ms 36588 KB Output is correct
4 Correct 91 ms 36588 KB Output is correct
5 Correct 77 ms 36588 KB Output is correct
6 Correct 51 ms 36588 KB Output is correct
7 Correct 40 ms 36588 KB Output is correct
8 Correct 122 ms 36588 KB Output is correct
9 Correct 110 ms 36588 KB Output is correct
10 Correct 128 ms 36588 KB Output is correct
11 Correct 127 ms 36588 KB Output is correct
12 Correct 110 ms 36588 KB Output is correct
13 Correct 114 ms 36620 KB Output is correct
14 Correct 110 ms 36652 KB Output is correct
15 Correct 108 ms 36652 KB Output is correct
16 Correct 112 ms 36652 KB Output is correct
17 Correct 109 ms 36652 KB Output is correct