Submission #385293

#TimeUsernameProblemLanguageResultExecution timeMemory
385293zoooma13Cheap flights (LMIO18_pigus_skrydziai)C++14
100 / 100
1369 ms80364 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n ,m; scanf("%d%d",&n,&m); vector <vector<pair<int ,int>>> adj(n+1); map <int ,int> con[n+1]; for(int u,v,w,i=0; i<m; i++){ scanf("%d%d%d",&u,&v,&w); adj[u].push_back({w ,v}); adj[v].push_back({w ,u}); con[u][v] = w; con[v][u] = w; } int64_t ans = 0; for(int u = 1; u <= n; u++){ sort(adj[u].rbegin() ,adj[u].rend()); int64_t tot = 0; for(auto&e : adj[u]) tot += e.first; if(adj[u].size() >= 2) tot = max(tot ,(int64_t)adj[u][0].first + adj[u][1].first + con[adj[u][0].second][adj[u][1].second]); ans = max(ans ,tot); } printf("%lld\n",ans); }

Compilation message (stderr)

pigus_skrydziai.cpp: In function 'int main()':
pigus_skrydziai.cpp:27:16: warning: format '%lld' expects argument of type 'long long int', but argument 2 has type 'int64_t' {aka 'long int'} [-Wformat=]
   27 |     printf("%lld\n",ans);
      |             ~~~^    ~~~
      |                |    |
      |                |    int64_t {aka long int}
      |                long long int
      |             %ld
pigus_skrydziai.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |     scanf("%d%d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~
pigus_skrydziai.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |         scanf("%d%d%d",&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...