Submission #392515

#TimeUsernameProblemLanguageResultExecution timeMemory
392515keta_tsimakuridzeCheap flights (LMIO18_pigus_skrydziai)C++14
37 / 100
1640 ms106380 KiB
#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)

pigus_skrydziai.cpp:11:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 |  main(){
      |       ^
pigus_skrydziai.cpp: In function 'int main()':
pigus_skrydziai.cpp:26:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for(int j=0;j<V[u].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...