제출 #1274141

#제출 시각아이디문제언어결과실행 시간메모리
1274141almaz경주 (Race) (IOI11_race)C++20
0 / 100
1 ms332 KiB
#include "race.h" #include <bits/stdc++.h> using namespace std; // #define int long long // #define endl '\n' #define ff first #define ss second #define pb push_back #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define ar array const int MOD = 1e9 + 7,INF = 1e9, N = 2e5 + 5; int best_path(int n, int k, int H[][2], int L[]){ vector <vector <pair<int,int>>> g(n + 1); vector <int> a; for(int i = 0;i < n - 1;i++){ g[H[i][0]].pb({H[i][1] , L[i]}); g[H[i][1]].pb({H[i][0] , L[i]}); a.pb(L[i]); } int ans = INF; for(int i = 0;i < n;i++){ int sum = 0; for(int j = i;j < n;i++){ sum += a[j]; if(sum == k){ ans = min(ans , (j - i)); break; } } } if(ans == INF){ return -1; } else{ return ans; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...