Submission #288161

#TimeUsernameProblemLanguageResultExecution timeMemory
288161TangentShortcut (IOI16_shortcut)C++17
0 / 100
1 ms256 KiB
#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 = max(b, get<2>(dists[changed])); change = max(cum[b] - cum[a] - c, 0LL); changed++; } res = min(res, max(get<0>(dists[0]) - change, get<0>(dists[changed]))); return res; }

Compilation message (stderr)

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])) {
      |                      ~~~~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...