Submission #416239

#TimeUsernameProblemLanguageResultExecution timeMemory
416239Runtime_error_Cheap flights (LMIO18_pigus_skrydziai)C++14
100 / 100
1798 ms113420 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair using namespace std; const ll inf = 3e5+9; ll n,m,ans; vector<pair<ll,ll> > adj[inf]; map<ll,ll> edge[inf]; int main(){ scanf("%lld%lld",&n,&m); for(ll i=1;i<=m;i++){ ll u,v,w; scanf("%lld%lld%lld",&u,&v,&w); adj[u].pb(mp(w,v)); adj[v].pb(mp(w,u)); edge[u][v] = edge[v][u] = w; } for(ll i=1;i<=n;i++){ sort(adj[i].rbegin(),adj[i].rend()); ll sum = 0; for(auto o:adj[i]) sum += o.first; ans = max(ans,sum); if(adj[i].size() > 1){ auto u = adj[i][0],v = adj[i][1]; ans = max(ans,u.first+v.first+edge[u.second][v.second]); } } printf("%lld\n",ans); }

Compilation message (stderr)

pigus_skrydziai.cpp: In function 'int main()':
pigus_skrydziai.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%lld%lld",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
pigus_skrydziai.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         scanf("%lld%lld%lld",&u,&v,&w);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...