#include "race.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
int ans = 1e9;
int best_path (int n, int k, int h[maxn][2], int l[maxn]){
for (int i = 0; i < n - 1; i++){
int duljina = 0;
for (int j = i; j < n - 1; j++){
duljina += l[j];
if (duljina > k) break;
if (duljina == k) ans = min(ans, j - i + 1);
}
}
if (ans == 1e9) return -1;
else return ans;
}
/*
int main (void){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, k, h[maxn][2], l[maxn];
cin >> n >> k;
for (int i = 0; i < n - 1; i++) cin >> h[i][0] >> h[i][1] >> l[i];
cout << best_path(n, k, h, l) << endl;
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... |