Submission #66348

# Submission time Handle Problem Language Result Execution time Memory
66348 2018-08-10T09:33:59 Z Talant Shortcut (IOI16_shortcut) C++17
0 / 100
3 ms 580 KB
#include "shortcut.h"
//#include "grader.cpp"

#include <bits/stdc++.h>

#define pb push_back
#define sc second
#define fr first
#define mk make_pair

using namespace std;

const int N = (1e6 + 7);
const int inf = (1e18 + 7);

long long p[N];
long long ans = inf;
long long dp[N],sf[N];
long long e[N];

long long find_shortcut(int n, vector<int> l, vector<int> d, int c)
{
      for (int i = 0; i < n - 1; i ++) {
            p[i + 1] = l[i];
            p[i + 1] += p[i];
      }

      for (int i = 0; i < n; i ++) {
            dp[i] = d[i];
            for (int j = 0; j < i; j ++) {
                  dp[i] = max(dp[i],p[i] - p[j] + d[j] + d[i]);
            }
            if (i > 0) dp[i] = max(dp[i - 1],dp[i]);
      }
      for (int i = n - 1; i >= 0; i --) {
            sf[i] = d[i];
            for (int j = i + 1; j < n; j ++) {
                  sf[i] = max(sf[i],p[j] - p[i] + d[j] + d[i]);
            }
            if (i < n - 1) sf[i] = max(sf[i + 1],sf[i]);
      }

      for (int i = 0; i < n; i ++) {
            for (int j = i + 1; j < n; j ++) {
                  long long mx = 0,mx2 = 0,e = 0,kk = 0;

                  for (int k = 0; k <= i; k ++)
                        mx = max(mx,p[i] - p[k] + d[k]);

                  for (int k = j; k < n; k ++)
                        mx2 = max(mx2,p[k] - p[j] + d[k]);

                  for (int k = i; k <= j; k ++) {
                        for (int o = k + 1; o <= j; o ++) {
                              e = max(e,min(p[o] - p[k] + d[k] + d[o],p[k] - p[i] + p[j] - p[o] + c + d[o] + d[k]));
                        }
                  }
                   for (int k = i; k <= j; k ++) {
                        long long d1 = p[k] - p[i];
                        long long d2 = p[j] - p[k];
                        kk = max(kk,min(d1 + c + mx2 + d[k],d2 + mx2 + d[k]));
                        kk = max(kk,min(d2 + c + mx + d[k],d1 + mx + d[k]));
                  }
                  ans = min(ans,max(kk,max(e,max(dp[i],max(sf[j],mx + mx2 + c)))));
            }
      }
      return min(dp[n - 1],ans);
}

Compilation message

shortcut.cpp:14:23: warning: overflow in implicit constant conversion [-Woverflow]
 const int inf = (1e18 + 7);
                 ~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 400 KB n = 4, 80 is a correct answer
2 Correct 2 ms 496 KB n = 9, 110 is a correct answer
3 Correct 3 ms 536 KB n = 4, 21 is a correct answer
4 Correct 3 ms 580 KB n = 3, 4 is a correct answer
5 Incorrect 3 ms 580 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 400 KB n = 4, 80 is a correct answer
2 Correct 2 ms 496 KB n = 9, 110 is a correct answer
3 Correct 3 ms 536 KB n = 4, 21 is a correct answer
4 Correct 3 ms 580 KB n = 3, 4 is a correct answer
5 Incorrect 3 ms 580 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 400 KB n = 4, 80 is a correct answer
2 Correct 2 ms 496 KB n = 9, 110 is a correct answer
3 Correct 3 ms 536 KB n = 4, 21 is a correct answer
4 Correct 3 ms 580 KB n = 3, 4 is a correct answer
5 Incorrect 3 ms 580 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 400 KB n = 4, 80 is a correct answer
2 Correct 2 ms 496 KB n = 9, 110 is a correct answer
3 Correct 3 ms 536 KB n = 4, 21 is a correct answer
4 Correct 3 ms 580 KB n = 3, 4 is a correct answer
5 Incorrect 3 ms 580 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 400 KB n = 4, 80 is a correct answer
2 Correct 2 ms 496 KB n = 9, 110 is a correct answer
3 Correct 3 ms 536 KB n = 4, 21 is a correct answer
4 Correct 3 ms 580 KB n = 3, 4 is a correct answer
5 Incorrect 3 ms 580 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 400 KB n = 4, 80 is a correct answer
2 Correct 2 ms 496 KB n = 9, 110 is a correct answer
3 Correct 3 ms 536 KB n = 4, 21 is a correct answer
4 Correct 3 ms 580 KB n = 3, 4 is a correct answer
5 Incorrect 3 ms 580 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 400 KB n = 4, 80 is a correct answer
2 Correct 2 ms 496 KB n = 9, 110 is a correct answer
3 Correct 3 ms 536 KB n = 4, 21 is a correct answer
4 Correct 3 ms 580 KB n = 3, 4 is a correct answer
5 Incorrect 3 ms 580 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 400 KB n = 4, 80 is a correct answer
2 Correct 2 ms 496 KB n = 9, 110 is a correct answer
3 Correct 3 ms 536 KB n = 4, 21 is a correct answer
4 Correct 3 ms 580 KB n = 3, 4 is a correct answer
5 Incorrect 3 ms 580 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -