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 "race.h"
#include<bits/stdc++.h>
using namespace std;
int best_path(int N, int K, int H[][2], int L[])
{
int psum[N];
psum[0] = 0;
for (int i = 0; i < N; i++){
psum[i+1] = psum[i] + L[i];
}
//for (auto x : psum) cout << x << " ";
bool found = false;
int ans = -1;
for (int d = 0; d <= N; d++){
if(found) break;
for (int i = 0; i <= N - d; i++){
if(i + d <= N){
if(psum[i + d] - psum[i] == K){
ans = d;
//cout << i + d << " " << i << "\n";
found = true;
break;
}
}
}
}
if(!found) return -1;
//cout << ans;
return ans;
}
# | 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... |