Submission #1069872

#TimeUsernameProblemLanguageResultExecution timeMemory
1069872TheQuantiXShortcut (IOI16_shortcut)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> #include "shortcut.h" using namespace std; using ll = long long; constexpr ll INF = 1000000000000000000LL; ll n, m, q, k, x, y, a, b, c; long long find_shortcut(int n, vector<int> l, vector<int> d, int c) { vector<ll> pref(n); for (int i = 0; i < n - 1; i++) { pref[i + 1] = pref[i] + l[i]; } deque< pair<ll, pair<ll, ll> > > v; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { ll dist = pref[j] - pref[i]; if (d[i] != 0 && d[j] != 0) { v.push_back({dist + d[i] + d[j], {i, j}}); } if (d[i] != 0) { v.push_back({dist + d[i], {i, j}}); } if (d[j] != 0) { v.push_back({dist + d[j], {i, j}}); } v.push_back({dist, {i, j}}); } } sort(v.rbegin(), v.rend()); ll ans = v[0].first; ll L = 0, R = n - 1; for (int i = 0; i < v.size(); i++) { L = max(L, v[i].second.first); R = min(R, v[i].second.second); // cout << v[i].first << ' ' << v[i].second.first << ' ' << v[i].second.second << '\n'; // cout << L << ' ' << R << '\n'; if (R > L && pref[R] - pref[L] >= c) { ans = min(ans, max(v[0].first - (pref[R] - pref[L]) + c, v[i + 1].first)); } else { break; } } return ans; }

Compilation message (stderr)

shortcut.cpp: In function 'long long int find_shortcut(int, std::vector<int>, std::vector<int>, int)':
shortcut.cpp:35:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for (int i = 0; i < v.size(); i++) {
      |                     ~~^~~~~~~~~~
#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...