Submission #550159

# Submission time Handle Problem Language Result Execution time Memory
550159 2022-04-17T12:05:53 Z fadi57 Cheap flights (LMIO18_pigus_skrydziai) C++14
12 / 100
3000 ms 113804 KB
#include<bits/stdc++.h>
using namespace std;

const int mx=5009;
typedef long long ll;
map<pair<int,int>,ll>ok;
vector<pair<int,ll>>adj[mx];
int n,m;
int main()
{
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        int x,y,w;
        cin>>x>>y>>w;
     adj[x].push_back({y,w});
       adj[y].push_back({x,w});
       ok[{x,y}]=w;
       ok[{y,x}]=w;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
            ll tmp=0;
         for(auto it:adj[i]){
            tmp+=it.second;
            for(auto itt:adj[it.first]){
                     if(itt.first==i){continue;}
                if(ok[{itt.first,i}]){
                   ans=max(ans,it.second+itt.second+ok[{itt.first,i}]);
                }
            }
         }
    if(tmp>=ans){ans=tmp;}
    }
    cout<<ans;

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 874 ms 3736 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 852 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 8 ms 980 KB Output is correct
19 Correct 20 ms 2636 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 874 ms 3736 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 852 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 8 ms 980 KB Output is correct
19 Correct 20 ms 2636 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Execution timed out 3086 ms 113804 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 548 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 548 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -