This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int best_path(int n, int k, int H[][2], int L[]) {
// vector<int> adj[n + 1];
// for(int i = 0; i < n - 1; i++) {
// int a, b;
// a = H[i][0];
// b = H[i][1];
// a++;
// b++;
// adj[a].push_back(b);
// adj[b].push_back(a);
// }
int S[n + 1] {};
for(int i = 0; i < n - 1; i++) {
S[i + 2] = S[i + 1] + L[i];
}
int mn = n;
for(int i = 2; i <= n; i++) {
for(int j = 1; j <= i - 1; j++) {
if(S[i] - S[j] == k) {
mn = min(mn, i - j);
}
}
}
if(mn == n) mn = -1;
return mn;
}
//int main() {
// cout << best_path(3, 3, {{0, 1}, {1, 2}}, {1, 1}) << '\n';
// return 0;
//}
# | 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... |