Submission #516965

# Submission time Handle Problem Language Result Execution time Memory
516965 2022-01-22T09:40:10 Z Tox123 Cheap flights (LMIO18_pigus_skrydziai) C++17
0 / 100
15 ms 15812 KB
#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 time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 284 KB Output is correct
3 Runtime error 1 ms 332 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 284 KB Output is correct
3 Runtime error 1 ms 332 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 15812 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 15812 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -