답안 #382169

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
382169 2021-03-26T15:51:19 Z mohamedsobhi777 Cheap flights (LMIO18_pigus_skrydziai) C++14
12 / 100
3000 ms 70080 KB
#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 = 3e5 + 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;

       bool case3 = 1;

       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;
              case3 &= w == 1;
       }

       if (case3 && m >= n)
       {
              ans = max(ans, 3ll);
       }
       else
       {

              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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 444 ms 2796 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 38 ms 1516 KB Output is correct
12 Correct 21 ms 1004 KB Output is correct
13 Correct 36 ms 1388 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 10 ms 748 KB Output is correct
19 Correct 57 ms 1644 KB Output is correct
20 Correct 34 ms 1388 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 444 ms 2796 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 38 ms 1516 KB Output is correct
12 Correct 21 ms 1004 KB Output is correct
13 Correct 36 ms 1388 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 10 ms 748 KB Output is correct
19 Correct 57 ms 1644 KB Output is correct
20 Correct 34 ms 1388 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Execution timed out 3083 ms 70080 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3070 ms 40292 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3070 ms 40292 KB Time limit exceeded
2 Halted 0 ms 0 KB -