답안 #962816

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
962816 2024-04-14T08:36:46 Z nguyentunglam Shortcut (IOI16_shortcut) C++17
0 / 100
1 ms 2392 KB
#include<bits/stdc++.h>
using namespace std;
#include "shortcut.h"

const int N = 3e3 + 10;

long long f[N][N];

long long find_shortcut(int n, std::vector<int> l, std::vector<int> d, int c)
{
  long long ans = 1e18;
    for(int x = 0; x < n; x++) for(int y = x + 1; y < n; y++) {
//      if (!(x == 1 && y == 3)) continue;
      for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) f[i][j] = (i == j ? 0 : 1e16);
      for(int i = 0; i + 1 < n; i++) f[i][i + 1] = f[i + 1][i] = l[i];
      f[x][y] = min(f[x][y], (long long) c);
      f[y][x] = min(f[y][x], (long long) c);
      for(int k = 0; k < n; k++) for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) {
        f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
      }
      long long cost = 0;
      for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) {
        cost = max(cost, f[i][j] + d[i] + d[j]);
//        if (f[i][j] + d[i] + d[j] == 110) {
//          cout << i << " " << j << endl;
//          cout << f[i][j] << " ";
//        }
      }
      ans = min(ans, cost);
    }
    return ans;
}

#ifdef ngu
int main()
{
  freopen ("task.inp", "r", stdin);
  freopen ("task.out", "w", stdout);
    int n, c;
    assert(2 == scanf("%d%d", &n, &c));

    std::vector<int> l(n - 1);
    std::vector<int> d(n);
    for (int i = 0; i < n - 1; i++)
        assert(1 == scanf("%d", &l[i]));
    for (int i = 0; i < n; i++)
        assert(1 == scanf("%d", &d[i]));

    long long t = find_shortcut(n, l, d, c);


    printf("%lld\n", t);

    return 0;
}
#endif // ngu
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB n = 4, 80 is a correct answer
2 Correct 1 ms 2392 KB n = 9, 110 is a correct answer
3 Correct 0 ms 452 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB n = 4, 80 is a correct answer
2 Correct 1 ms 2392 KB n = 9, 110 is a correct answer
3 Correct 0 ms 452 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB n = 4, 80 is a correct answer
2 Correct 1 ms 2392 KB n = 9, 110 is a correct answer
3 Correct 0 ms 452 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB n = 4, 80 is a correct answer
2 Correct 1 ms 2392 KB n = 9, 110 is a correct answer
3 Correct 0 ms 452 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB n = 4, 80 is a correct answer
2 Correct 1 ms 2392 KB n = 9, 110 is a correct answer
3 Correct 0 ms 452 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB n = 4, 80 is a correct answer
2 Correct 1 ms 2392 KB n = 9, 110 is a correct answer
3 Correct 0 ms 452 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB n = 4, 80 is a correct answer
2 Correct 1 ms 2392 KB n = 9, 110 is a correct answer
3 Correct 0 ms 452 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB n = 4, 80 is a correct answer
2 Correct 1 ms 2392 KB n = 9, 110 is a correct answer
3 Correct 0 ms 452 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -