Submission #288163

# Submission time Handle Problem Language Result Execution time Memory
288163 2020-09-01T09:28:39 Z Tangent Shortcut (IOI16_shortcut) C++17
0 / 100
0 ms 384 KB
#include <bits/stdc++.h>
#include "shortcut.h"

using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(), order_of_key()

typedef long long ll;
typedef long double dd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<dd, dd> pdd;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<dd> vdd;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;
typedef vector<vii> vvii;
typedef vector<vll> vvll;
typedef vector<vdd> vvdd;
typedef vector<vpii> vvpii;
typedef vector<vpll> vvpll;
typedef vector<vpdd> vvpdd;
typedef vector<bool> vb;

const int inf = 1 << 30;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define ffor(i, a, b) for(ll i = a; i < b; i++)
#define forin(x, a) for (auto &x: a)
#define all(x) x.begin(), x.end()

#ifdef TEST
#define dbg(x) cout << #x << ": " << x << '\n';
#define dbgc(x) cout << #x << ":"; forin(a, x) { cout << " " << a; } cout << endl;
#define tassert(x) assert(x);
#else
#define dbg(x)
#define dbgc(x)
#define tassert(x)
#endif

long long find_shortcut(int n, std::vector<int> l, std::vector<int> d, int c) {
    if (n == 2) {
        return min(l[0], c) + d[0] + d[1];
    }
    vector<tuple<ll, int, int>> dists;
    vll cum = {0};
    forin(x, l) {
        cum.emplace_back(cum.back() + x);
    }
    rep(i, n - 1) {
        ffor(j, i + 1, n) {
            dists.emplace_back(d[i] + d[j] + cum[j] - cum[i], i, j);
        }
    }
    sort(dists.rbegin(), dists.rend());
    int a = get<1>(dists[0]), b = get<2>(dists[0]);
    ll change = max(cum[b] - cum[a] - c, 0LL), changed = 1;
    ll res = max(get<0>(dists[0]) - change, get<0>(dists[1]));
    while (change && changed < dists.size() && get<0>(dists[0]) - change < get<0>(dists[changed])) {
        res = min(res, get<0>(dists[changed]));
        a = max(a, get<1>(dists[changed]));
        b = min(b, get<2>(dists[changed]));
        change = max(cum[b] - cum[a] - c, 0LL);
        changed++;
    }
    res = min(res, max(get<0>(dists[0]) - change, (changed < dists.size() ? get<0>(dists[changed]) : 0)));

    return res;
}

Compilation message

shortcut.cpp: In function 'long long int find_shortcut(int, std::vector<int>, std::vector<int>, int)':
shortcut.cpp:66:30: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::tuple<long long int, int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |     while (change && changed < dists.size() && get<0>(dists[0]) - change < get<0>(dists[changed])) {
      |                      ~~~~~~~~^~~~~~~~~~~~~~
shortcut.cpp:73:60: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::tuple<long long int, int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |     res = min(res, max(get<0>(dists[0]) - change, (changed < dists.size() ? get<0>(dists[changed]) : 0)));
      |                                                    ~~~~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB n = 4, 80 is a correct answer
2 Correct 0 ms 256 KB n = 9, 110 is a correct answer
3 Correct 0 ms 384 KB n = 4, 21 is a correct answer
4 Correct 0 ms 256 KB n = 3, 4 is a correct answer
5 Correct 0 ms 256 KB n = 2, 62 is a correct answer
6 Correct 0 ms 256 KB n = 2, 3 is a correct answer
7 Correct 0 ms 256 KB n = 3, 29 is a correct answer
8 Correct 0 ms 256 KB n = 2, 3 is a correct answer
9 Correct 0 ms 256 KB n = 2, 3 is a correct answer
10 Correct 0 ms 256 KB n = 2, 2000000001 is a correct answer
11 Incorrect 0 ms 256 KB n = 2, incorrect answer: jury 3000000000 vs contestant -1294967296
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB n = 4, 80 is a correct answer
2 Correct 0 ms 256 KB n = 9, 110 is a correct answer
3 Correct 0 ms 384 KB n = 4, 21 is a correct answer
4 Correct 0 ms 256 KB n = 3, 4 is a correct answer
5 Correct 0 ms 256 KB n = 2, 62 is a correct answer
6 Correct 0 ms 256 KB n = 2, 3 is a correct answer
7 Correct 0 ms 256 KB n = 3, 29 is a correct answer
8 Correct 0 ms 256 KB n = 2, 3 is a correct answer
9 Correct 0 ms 256 KB n = 2, 3 is a correct answer
10 Correct 0 ms 256 KB n = 2, 2000000001 is a correct answer
11 Incorrect 0 ms 256 KB n = 2, incorrect answer: jury 3000000000 vs contestant -1294967296
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB n = 4, 80 is a correct answer
2 Correct 0 ms 256 KB n = 9, 110 is a correct answer
3 Correct 0 ms 384 KB n = 4, 21 is a correct answer
4 Correct 0 ms 256 KB n = 3, 4 is a correct answer
5 Correct 0 ms 256 KB n = 2, 62 is a correct answer
6 Correct 0 ms 256 KB n = 2, 3 is a correct answer
7 Correct 0 ms 256 KB n = 3, 29 is a correct answer
8 Correct 0 ms 256 KB n = 2, 3 is a correct answer
9 Correct 0 ms 256 KB n = 2, 3 is a correct answer
10 Correct 0 ms 256 KB n = 2, 2000000001 is a correct answer
11 Incorrect 0 ms 256 KB n = 2, incorrect answer: jury 3000000000 vs contestant -1294967296
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB n = 4, 80 is a correct answer
2 Correct 0 ms 256 KB n = 9, 110 is a correct answer
3 Correct 0 ms 384 KB n = 4, 21 is a correct answer
4 Correct 0 ms 256 KB n = 3, 4 is a correct answer
5 Correct 0 ms 256 KB n = 2, 62 is a correct answer
6 Correct 0 ms 256 KB n = 2, 3 is a correct answer
7 Correct 0 ms 256 KB n = 3, 29 is a correct answer
8 Correct 0 ms 256 KB n = 2, 3 is a correct answer
9 Correct 0 ms 256 KB n = 2, 3 is a correct answer
10 Correct 0 ms 256 KB n = 2, 2000000001 is a correct answer
11 Incorrect 0 ms 256 KB n = 2, incorrect answer: jury 3000000000 vs contestant -1294967296
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB n = 4, 80 is a correct answer
2 Correct 0 ms 256 KB n = 9, 110 is a correct answer
3 Correct 0 ms 384 KB n = 4, 21 is a correct answer
4 Correct 0 ms 256 KB n = 3, 4 is a correct answer
5 Correct 0 ms 256 KB n = 2, 62 is a correct answer
6 Correct 0 ms 256 KB n = 2, 3 is a correct answer
7 Correct 0 ms 256 KB n = 3, 29 is a correct answer
8 Correct 0 ms 256 KB n = 2, 3 is a correct answer
9 Correct 0 ms 256 KB n = 2, 3 is a correct answer
10 Correct 0 ms 256 KB n = 2, 2000000001 is a correct answer
11 Incorrect 0 ms 256 KB n = 2, incorrect answer: jury 3000000000 vs contestant -1294967296
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB n = 4, 80 is a correct answer
2 Correct 0 ms 256 KB n = 9, 110 is a correct answer
3 Correct 0 ms 384 KB n = 4, 21 is a correct answer
4 Correct 0 ms 256 KB n = 3, 4 is a correct answer
5 Correct 0 ms 256 KB n = 2, 62 is a correct answer
6 Correct 0 ms 256 KB n = 2, 3 is a correct answer
7 Correct 0 ms 256 KB n = 3, 29 is a correct answer
8 Correct 0 ms 256 KB n = 2, 3 is a correct answer
9 Correct 0 ms 256 KB n = 2, 3 is a correct answer
10 Correct 0 ms 256 KB n = 2, 2000000001 is a correct answer
11 Incorrect 0 ms 256 KB n = 2, incorrect answer: jury 3000000000 vs contestant -1294967296
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB n = 4, 80 is a correct answer
2 Correct 0 ms 256 KB n = 9, 110 is a correct answer
3 Correct 0 ms 384 KB n = 4, 21 is a correct answer
4 Correct 0 ms 256 KB n = 3, 4 is a correct answer
5 Correct 0 ms 256 KB n = 2, 62 is a correct answer
6 Correct 0 ms 256 KB n = 2, 3 is a correct answer
7 Correct 0 ms 256 KB n = 3, 29 is a correct answer
8 Correct 0 ms 256 KB n = 2, 3 is a correct answer
9 Correct 0 ms 256 KB n = 2, 3 is a correct answer
10 Correct 0 ms 256 KB n = 2, 2000000001 is a correct answer
11 Incorrect 0 ms 256 KB n = 2, incorrect answer: jury 3000000000 vs contestant -1294967296
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB n = 4, 80 is a correct answer
2 Correct 0 ms 256 KB n = 9, 110 is a correct answer
3 Correct 0 ms 384 KB n = 4, 21 is a correct answer
4 Correct 0 ms 256 KB n = 3, 4 is a correct answer
5 Correct 0 ms 256 KB n = 2, 62 is a correct answer
6 Correct 0 ms 256 KB n = 2, 3 is a correct answer
7 Correct 0 ms 256 KB n = 3, 29 is a correct answer
8 Correct 0 ms 256 KB n = 2, 3 is a correct answer
9 Correct 0 ms 256 KB n = 2, 3 is a correct answer
10 Correct 0 ms 256 KB n = 2, 2000000001 is a correct answer
11 Incorrect 0 ms 256 KB n = 2, incorrect answer: jury 3000000000 vs contestant -1294967296
12 Halted 0 ms 0 KB -