Submission #237061

# Submission time Handle Problem Language Result Execution time Memory
237061 2020-06-04T10:53:02 Z Aldas25 Cheap flights (LMIO18_pigus_skrydziai) C++14
100 / 100
1526 ms 99680 KB
#include <bits/stdc++.h>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int MAXN = 300100;

int n, m;
ll cnt[MAXN];
map<ll, ll> edges;
vector<pair<ll, int>> adj[MAXN];

ll edgeId (int u, int v) {
    return ((ll)u)*((ll)n+5) + ((ll)v);
}

int main()
{
    FAST_IO;

    //ifstream cin ("lmio_2018_3e2_pigus_skrydziai_vyr.in");
    //ofstream cout ("lmio_2018_3e2_pigus_skrydziai_vyr.out");

    cin >> n >> m;
    REP(m) {
        int u, v; cin >> u >> v;
        ll w; cin >> w;
        adj[u].pb({w,v});
        adj[v].pb({w,u});
        cnt[u] += w;
        cnt[v] += w;
        edges[edgeId(u,v)] = w;
        edges[edgeId(v,u)] = w;
    }

    ll ans = 0;
    FOR(i, 1, n) ans = max(ans, cnt[i]);

    FOR(i, 1, n) {
        if ((int)adj[i].size() < 2) continue;
        sort(adj[i].begin(), adj[i].end());
        reverse(adj[i].begin(), adj[i].end());
        ll cur = adj[i][0].f + adj[i][1].f;
        int u = adj[i][0].s, v = adj[i][1].s;
        ans = max(ans, cur + edges[edgeId(u,v)]);
    }

    cout << ans << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7424 KB Output is correct
2 Correct 8 ms 7424 KB Output is correct
3 Correct 8 ms 7424 KB Output is correct
4 Correct 9 ms 7424 KB Output is correct
5 Correct 8 ms 7424 KB Output is correct
6 Correct 24 ms 10880 KB Output is correct
7 Correct 10 ms 7424 KB Output is correct
8 Correct 8 ms 7424 KB Output is correct
9 Correct 9 ms 7424 KB Output is correct
10 Correct 8 ms 7424 KB Output is correct
11 Correct 9 ms 7552 KB Output is correct
12 Correct 9 ms 7424 KB Output is correct
13 Correct 9 ms 7424 KB Output is correct
14 Correct 8 ms 7424 KB Output is correct
15 Correct 9 ms 7424 KB Output is correct
16 Correct 8 ms 7424 KB Output is correct
17 Correct 9 ms 7424 KB Output is correct
18 Correct 9 ms 7552 KB Output is correct
19 Correct 10 ms 7808 KB Output is correct
20 Correct 9 ms 7424 KB Output is correct
21 Correct 8 ms 7424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7424 KB Output is correct
2 Correct 8 ms 7424 KB Output is correct
3 Correct 8 ms 7424 KB Output is correct
4 Correct 9 ms 7424 KB Output is correct
5 Correct 8 ms 7424 KB Output is correct
6 Correct 24 ms 10880 KB Output is correct
7 Correct 10 ms 7424 KB Output is correct
8 Correct 8 ms 7424 KB Output is correct
9 Correct 9 ms 7424 KB Output is correct
10 Correct 8 ms 7424 KB Output is correct
11 Correct 9 ms 7552 KB Output is correct
12 Correct 9 ms 7424 KB Output is correct
13 Correct 9 ms 7424 KB Output is correct
14 Correct 8 ms 7424 KB Output is correct
15 Correct 9 ms 7424 KB Output is correct
16 Correct 8 ms 7424 KB Output is correct
17 Correct 9 ms 7424 KB Output is correct
18 Correct 9 ms 7552 KB Output is correct
19 Correct 10 ms 7808 KB Output is correct
20 Correct 9 ms 7424 KB Output is correct
21 Correct 8 ms 7424 KB Output is correct
22 Correct 1526 ms 99680 KB Output is correct
23 Correct 556 ms 94968 KB Output is correct
24 Correct 34 ms 11260 KB Output is correct
25 Correct 15 ms 8576 KB Output is correct
26 Correct 15 ms 8576 KB Output is correct
27 Correct 11 ms 7936 KB Output is correct
28 Correct 493 ms 44196 KB Output is correct
29 Correct 139 ms 21752 KB Output is correct
30 Correct 246 ms 29304 KB Output is correct
31 Correct 9 ms 7552 KB Output is correct
32 Correct 9 ms 7552 KB Output is correct
33 Correct 590 ms 97532 KB Output is correct
34 Correct 465 ms 88056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 283 ms 40312 KB Output is correct
2 Correct 779 ms 85948 KB Output is correct
3 Correct 211 ms 33400 KB Output is correct
4 Correct 461 ms 57848 KB Output is correct
5 Correct 1200 ms 76608 KB Output is correct
6 Correct 108 ms 28280 KB Output is correct
7 Correct 275 ms 68088 KB Output is correct
8 Correct 306 ms 65912 KB Output is correct
9 Correct 11 ms 9856 KB Output is correct
10 Correct 109 ms 28408 KB Output is correct
11 Correct 314 ms 65628 KB Output is correct
12 Correct 234 ms 49272 KB Output is correct
13 Correct 9 ms 7424 KB Output is correct
14 Correct 179 ms 25336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 283 ms 40312 KB Output is correct
2 Correct 779 ms 85948 KB Output is correct
3 Correct 211 ms 33400 KB Output is correct
4 Correct 461 ms 57848 KB Output is correct
5 Correct 1200 ms 76608 KB Output is correct
6 Correct 108 ms 28280 KB Output is correct
7 Correct 275 ms 68088 KB Output is correct
8 Correct 306 ms 65912 KB Output is correct
9 Correct 11 ms 9856 KB Output is correct
10 Correct 109 ms 28408 KB Output is correct
11 Correct 314 ms 65628 KB Output is correct
12 Correct 234 ms 49272 KB Output is correct
13 Correct 9 ms 7424 KB Output is correct
14 Correct 179 ms 25336 KB Output is correct
15 Correct 501 ms 46612 KB Output is correct
16 Correct 514 ms 44244 KB Output is correct
17 Correct 547 ms 49240 KB Output is correct
18 Correct 768 ms 59248 KB Output is correct
19 Correct 195 ms 27236 KB Output is correct
20 Correct 789 ms 64608 KB Output is correct
21 Correct 787 ms 88692 KB Output is correct
22 Correct 502 ms 61176 KB Output is correct
23 Correct 593 ms 59740 KB Output is correct
24 Correct 345 ms 36316 KB Output is correct
25 Correct 957 ms 66936 KB Output is correct
26 Correct 797 ms 61100 KB Output is correct
27 Correct 741 ms 58744 KB Output is correct
28 Correct 8 ms 7424 KB Output is correct
29 Correct 8 ms 7424 KB Output is correct
30 Correct 8 ms 7424 KB Output is correct
31 Correct 9 ms 7424 KB Output is correct
32 Correct 8 ms 7424 KB Output is correct
33 Correct 24 ms 10880 KB Output is correct
34 Correct 10 ms 7424 KB Output is correct
35 Correct 8 ms 7424 KB Output is correct
36 Correct 9 ms 7424 KB Output is correct
37 Correct 8 ms 7424 KB Output is correct
38 Correct 9 ms 7552 KB Output is correct
39 Correct 9 ms 7424 KB Output is correct
40 Correct 9 ms 7424 KB Output is correct
41 Correct 8 ms 7424 KB Output is correct
42 Correct 9 ms 7424 KB Output is correct
43 Correct 8 ms 7424 KB Output is correct
44 Correct 9 ms 7424 KB Output is correct
45 Correct 9 ms 7552 KB Output is correct
46 Correct 10 ms 7808 KB Output is correct
47 Correct 9 ms 7424 KB Output is correct
48 Correct 8 ms 7424 KB Output is correct
49 Correct 1526 ms 99680 KB Output is correct
50 Correct 556 ms 94968 KB Output is correct
51 Correct 34 ms 11260 KB Output is correct
52 Correct 15 ms 8576 KB Output is correct
53 Correct 15 ms 8576 KB Output is correct
54 Correct 11 ms 7936 KB Output is correct
55 Correct 493 ms 44196 KB Output is correct
56 Correct 139 ms 21752 KB Output is correct
57 Correct 246 ms 29304 KB Output is correct
58 Correct 9 ms 7552 KB Output is correct
59 Correct 9 ms 7552 KB Output is correct
60 Correct 590 ms 97532 KB Output is correct
61 Correct 465 ms 88056 KB Output is correct