Submission #258830

#TimeUsernameProblemLanguageResultExecution timeMemory
258830uacoder123Cheap flights (LMIO18_pigus_skrydziai)C++14
100 / 100
2009 ms99192 KiB
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define FOR(i,a,b) for (auto i = (a); i <= (b); ++i) #define NFOR(i,a,b) for(auto i = (a); i >= (b); --i) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) #define mp(i,a) make_pair(i,a) #define pb(a) push_back(a) #define bit(x,b) (x&(1LL<<b)) typedef long long int lli; typedef pair <lli,lli> ii; typedef pair <ii,lli> iii; typedef vector <lli> vi; map<ii,lli> ma; vector<ii> al[300001]; int main() { lli n,m; cin>>n>>m; for(lli i=0;i<m;++i) { lli f,s,w; cin>>f>>s>>w; al[f].pb(mp(w,s)); al[s].pb(mp(w,f)); ma[mp(f,s)]=w; ma[mp(s,f)]=w; } lli ans=0; for(lli i=1;i<=n;++i) { sort(all(al[i]),greater<ii>()); lli s=0; for(lli j=0;j<al[i].size();++j) s+=al[i][j].F; if(al[i].size()>1&&ma.find(mp(al[i][0].S,al[i][1].S))!=ma.end()) s=max(s,al[i][0].F+al[i][1].F+ma[mp(al[i][0].S,al[i][1].S)]); ans=max(ans,s); } cout<<ans<<endl; return(0); }

Compilation message (stderr)

pigus_skrydziai.cpp: In function 'int main()':
pigus_skrydziai.cpp:37:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(lli j=0;j<al[i].size();++j)
                     ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...