Submission #516965

#TimeUsernameProblemLanguageResultExecution timeMemory
516965Tox123Cheap flights (LMIO18_pigus_skrydziai)C++17
0 / 100
15 ms15812 KiB
#include <iostream> #include <list> #include <vector> #include <algorithm> #include <iterator> #include <cmath> using namespace std; struct PathD{ int OtherCity; int Price; }; int main(){ int n, m; cin >> n >> m; int Sums[m] = {0}; list<PathD> PathData[n]; int MaxSum = 0; for(int PathIndex = 0;PathIndex<m;PathIndex++){ int CityA, CityB, Price; cin >> CityA >> CityB >> Price; CityA--; CityB--; PathD CityAPathD; CityAPathD.OtherCity = CityB; CityAPathD.Price = Price; PathD CityBPathD; CityBPathD.OtherCity = CityA; CityBPathD.Price = Price; for(auto it1 = PathData[CityA].begin();it1!=PathData[CityA].end();it1++){ for(auto it2 = PathData[CityB].begin();it2!=PathData[CityB].end();it2++){ PathD PD1 = *it1; PathD PD2 = *it2; if(PD1.OtherCity==PD2.OtherCity){ MaxSum = max(MaxSum,PD1.Price+PD2.Price+Price); } } } PathData[CityA].push_front(CityAPathD); PathData[CityB].push_front(CityBPathD); Sums[CityA] += Price; MaxSum = max(MaxSum,Sums[CityA]); Sums[CityB] += Price; MaxSum = max(MaxSum,Sums[CityB]); } cout << MaxSum << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...