Submission #304938

#TimeUsernameProblemLanguageResultExecution timeMemory
304938computerboxCheap flights (LMIO18_pigus_skrydziai)C++14
12 / 100
3090 ms192928 KiB
#include <bits/stdc++.h> #define FLASH ios_base::sync_with_stdio(0); #define ll long long #define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl; #define deb(x)cout<<"#x = "<<(x)<<endl; #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define endl "\n" #define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n"; #define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n"; using namespace std; unordered_map<ll,ll>adj[300010]; ll n,m; int main(){ FLASH; cin>>n>>m; for(ll i=1;i<=m;i++) { ll x,y,z; cin>>x>>y>>z; adj[x][y]=z; adj[y][x]=z; } ll maxx=0; ll summ=0; for(ll i=1;i<=n;i++) { summ=0; for(auto j:adj[i])summ+=j.second; maxx=max(maxx,summ); } for(ll i=1;i<=n;i++) { for(auto j:adj[i]) { for(auto j1:adj[j.first]) { ll y=j1.first; if(y==i)continue; auto yy=j1.first; ll ch=adj[yy][i]; if(ch!=0) { maxx=max(maxx,j.second+j1.second+ch); } } } } cout<<maxx<<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...