이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |