Submission #942150

#TimeUsernameProblemLanguageResultExecution timeMemory
942150MathiasCheap flights (LMIO18_pigus_skrydziai)C++14
12 / 100
3046 ms93628 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 5e5+7; long long t[MAXN]; vector<pair<int,int> > v; vector<int>g[MAXN]; map<pair<int,int>,long long>w; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,m,a,b,c,s; long long res=0; cin>>n>>m; for(int i=1;i<=m;i++){ cin>>a>>b>>c; t[a]+=c; t[b]+=c; g[a].push_back(b); g[b].push_back(a); v.push_back({a,b}); w[{a,b}]=w[{b,a}]=c; } for(int i=1;i<=n;i++){ res=max(res,t[i]); } for(auto k:v){ a=k.first; b=k.second; for(int i=0;i<g[a].size();i++){ s=g[a][i]; if(w.count({b,s})) res=max(res,w[{a,b}]+w[{a,s}]+w[{b,s}]); } } cout<<res<<'\n'; return 0; }

Compilation message (stderr)

pigus_skrydziai.cpp: In function 'int main()':
pigus_skrydziai.cpp:25:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   for(int i=0;i<g[a].size();i++){
      |               ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...