Submission #382170

# Submission time Handle Problem Language Result Execution time Memory
382170 2021-03-26T15:52:32 Z mohamedsobhi777 Cheap flights (LMIO18_pigus_skrydziai) C++14
12 / 100
3000 ms 70496 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;
              if (w != 1)
                     case3 = 0;
       }

       if (case3)
       {
              if (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;
}
# Verdict Execution time Memory 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 421 ms 2924 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 34 ms 1412 KB Output is correct
12 Correct 20 ms 1004 KB Output is correct
13 Correct 34 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 55 ms 1644 KB Output is correct
20 Correct 31 ms 1388 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory 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 421 ms 2924 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 34 ms 1412 KB Output is correct
12 Correct 20 ms 1004 KB Output is correct
13 Correct 34 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 55 ms 1644 KB Output is correct
20 Correct 31 ms 1388 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Execution timed out 3075 ms 70496 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 205 ms 21484 KB Output is correct
2 Incorrect 520 ms 40300 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 205 ms 21484 KB Output is correct
2 Incorrect 520 ms 40300 KB Output isn't correct
3 Halted 0 ms 0 KB -