#include "race.h"
#include "bits/stdc++.h"
using namespace std;
int best_path(int n, int k, int h[][2], int l[])
{
    /*
    vector<vector< pair<int, int> >> v(n + 1, vector< pair<int, int> >(0));
    for (int i = 0; i < n; ++i)
    {
        v[h[i][0]].push_back({h[i][1], l[i]});
        v[h[i][1]].push_back({h[i][0], l[i]});
    }
    */
    vector<int> dp(n + 5);
    --n;
    for (int i = 1; i <= n; ++i)
    {
        dp[i] = (dp[i - 1] + l[i - 1]);
    }
    int res = 1e9;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = i; j <= n; ++j)
        {
            if (dp[j] - dp[i - 1] == k)
            {
                res = min(res, j - i + 1);
                break;
            }
        }
    }
    if (res == 1e9)
    {
        return -1;
    }
    return res;
}
| # | 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... |