# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
392515 | keta_tsimakuridze | Cheap flights (LMIO18_pigus_skrydziai) | C++14 | 1640 ms | 106380 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define f first
#define int long long
#define s second
using namespace std;
const int N=2e5+5,mod=1e9+7;
int t,n,m;
map<int,int> f[N];
vector<pair<int,int> >V[N];
string s;
main(){
// t=1;
cin>>n>>m;
for(int i=1;i<=m;i++){
int u,v,w;
cin>>u>>v>>w;
V[u].push_back({w,v});
V[v].push_back({w,u});
f[u][v]=f[v][u]=w;
}
int ans = 0;
for(int u=1;u<=n;u++){
sort(V[u].begin(),V[u].end());
reverse(V[u].begin(),V[u].end());
int sum=0;
for(int j=0;j<V[u].size();j++){
sum += V[u][j].f;
}
if(V[u].size()>1) ans=max(ans,V[u][0].f+V[u][1].f+f[V[u][0].s][V[u][1].s]);
ans=max(ans,sum);
}
cout<<ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |