제출 #382165

#제출 시각아이디문제언어결과실행 시간메모리
382165mohamedsobhi777Cheap flights (LMIO18_pigus_skrydziai)C++14
12 / 100
3099 ms70040 KiB
#include <bits/stdc++.h> using namespace std; #define vi vector<int> #define vll vector<ll> #define vii vector<pair<int, int>> #define pii pair<int, int> #define pll pair<ll, ll> #define loop(_) for (int __ = 0; __ < (_); ++__) #define pb push_back #define f first #define s second #define sz(_) ((int)_.size()) #define all(_) _.begin(), _.end() #define lb lower_bound #define ub upper_bound using ll = long long; using ld = long double; const int N = 1e5 + 7; const ll mod = 1e9 + 7; int n , m; ll a[N] ; map<pii,ll> cost ; int main() { ios_base::sync_with_stdio(0); cin.tie(0); #ifndef ONLINE_JUDGE #endif cin >> n >> m; ll ans = 0 ; for (int i = 0; i < m; ++i) { int u, v, w; cin >> u >> v >> w; a[u] += w; a[v] += w; ans = max({ans , a[u] , a[v]}) ; cost[{u , v}] = cost[{v , u}] = w ; } for(int i = 1;i <= n;++ i){ for(int j = i + 1;j <= n;++ j){ for(int k = j + 1; k <= n; ++ k){ if( cost[{i , j}] && cost[{i , k}] && cost[{j , k}] ){ ans = max(ans , cost[{i , j}] + cost[{j , k}] + cost[{i , k}]) ; } } } } cout<< ans ; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...