Submission #1307415

#TimeUsernameProblemLanguageResultExecution timeMemory
1307415robijoyRace (IOI11_race)C++20
0 / 100
1 ms572 KiB
/* * Starting with the name of almighty ALLAH */ #include <bits/stdc++.h> #include "race.h" using namespace std; #define ll long long const int N = 1e2+3; vector<int> g[N]; int best_path(int n, int k, int H[][2], int L[]) { n--; for (int i = 0; i < n; ++i) { g[H[i][0]].push_back(H[i][1]); g[H[i][1]].push_back(H[i][0]); } vector<ll> li; li.push_back(0); for (int i = 0; i < n; ++i) li.push_back(L[i]); for (int i = 1; i < n+1; ++i) li[i] += li[i-1]; int mn = 1e9; for (int i = 0; i < n+1; ++i) { for (int j = i+1; j < n+1; ++j) { ll diff = li[j] - li[i]; if(diff == k) { mn = min(mn, (j-i)); } } } return mn; } // void solve() { // int n, k; cin>>n>>k; // int H[n-1][2]; // int L[n-1]; // for (int i = 0; i < n-1; ++i) // { // int u,v,w; // cin>>u>>v>>w; // H[i][0] = u; // H[i][1] = v; // L[i] = w; // } // cout<<best_path(n,k,H,L)<<endl; // } // int32_t main() { // ios::sync_with_stdio(false); // cin.tie(0); // int t = 1; // // cin >> t; // while (t--) solve(); // }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...