답안 #1005158

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005158 2024-06-22T08:12:08 Z Mardonbekhazratov 경주 (Race) (IOI11_race) C++17
0 / 100
1 ms 2396 KB
#include "race.h"
#include<bits/stdc++.h>

using namespace std;

int n;
vector<vector<pair<int,int>>>v;

int best_path(int N, int K, int H[][2], int L[]){
	n=N;
	vector<int>pref(n);
	pref[0]=0;
	v.resize(n);
	for(int i=0;i<n-1;i++){
		v[H[i][0]].push_back({H[i][1],L[i]});
		v[H[i][1]].push_back({H[i][0],L[i]});
		pref[i+1]=pref[i]+L[i];
	}
	int ans=n;
	for(int i=0;i<n-1;i++){
		auto pos=lower_bound(pref.begin(),pref.end(),pref[i]+K)-pref.begin();
		if(pos!=n && pref[pos]-pref[i]==K) ans=min(ans,(int)pos-i);
	}
	return (ans==n ? -1 : ans+1);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -