| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1324366 | silence25 | 경주 (Race) (IOI11_race) | C++20 | 0 ms | 0 KiB |
#include "race.h"
#include "bits/stdc++.h"
using namespace std;
const int INF = 1e9 + 7;
const int N = 105;
ll pref[N];
int best_path(int n,int k,int h[][2],int l[]){
int m = n - 1;
for(int i = 1;i<=m;++i)
pref[i] = pref[i - 1] + l[i - 1];
int ans = INF;
for(int l = 1;l<=m;++l)
for(int r = l;r<=m;++r)
if(pref[r] - pref[l - 1] == k)
ans = min(ans,r - l + 1);
if(ans == INF)
ans = -1;
return ans;
}