답안 #516972

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
516972 2022-01-22T09:49:09 Z Tox123 Cheap flights (LMIO18_pigus_skrydziai) C++17
0 / 100
11 ms 17028 KB
#include <iostream>
#include <list>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cmath>

using namespace std;

struct PathD{
    int OtherCity;
    long long Price;
};

int main(){
    int n, m;
    cin >> n >> m;
    long long Sums[m] = {0};
    list<PathD> PathData[n];
    long long 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Runtime error 1 ms 332 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Runtime error 1 ms 332 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 11 ms 17028 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 11 ms 17028 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -