Submission #795924

#TimeUsernameProblemLanguageResultExecution timeMemory
795924allllekssssaCheap flights (LMIO18_pigus_skrydziai)C++14
12 / 100
3063 ms96956 KiB
#include<stdio.h> #include<iostream> #include<algorithm> #include<vector> #include<map> using namespace std; #define mp make_pair #define pb push_back #define pii pair<int, int> const int maxN = 1e6 + 10; vector<pii> v[maxN]; long long cnt[maxN]; map<pii, int> mapa; int n, m; int mx; int main() { cin >> n >> m; for (int i = 1; i<=m; i++) { int x, y, z; scanf("%d%d%d", &x, &y, &z); cnt[x]+=z; cnt[y]+=z; v[x].pb(mp(y,z)); v[y].pb(mp(x, z)); mapa[mp(x, y)] = z; mapa[mp(y, x)] = z; mx = max(mx, z); } long long ans = 0; for (int i = 1; i<=n; i++) { ans = max(ans, cnt[i]); } if (mx > 1) { for (int x = 1; x<=n; x++) { for (auto y : v[x]) { for (auto z: v[y.first]) { if (mapa.count(mp(x, z.first))) ans = max(ans, 1ll * y.second + z.second + mapa[mp(x, z.first)]); } } } } cout << ans << endl; return 0; }

Compilation message (stderr)

pigus_skrydziai.cpp: In function 'int main()':
pigus_skrydziai.cpp:28:11: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |      scanf("%d%d%d", &x, &y, &z);
      |      ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...