답안 #247398

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
247398 2020-07-11T10:21:21 Z dolphingarlic Cheap flights (LMIO18_pigus_skrydziai) C++14
100 / 100
1670 ms 99620 KB
/*
LMIO 2018 Pigus Skrydziai
- We either take all edges incident to one node or we take a triangle
- There are 
*/

#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

ll prof[300001];
vector<pair<ll, int>> graph[300001];
map<pair<int, int>, ll> edges;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    while (m--) {
        int a, b;
        ll v;
        cin >> a >> b >> v;
        prof[a] += v, prof[b] += v;
        graph[a].push_back({v, b});
        graph[b].push_back({v, a});
        edges[{a, b}] = edges[{b, a}] = v;
    }
    ll ans = *max_element(prof + 1, prof + n + 1);
    FOR(i, 1, n + 1) {
        sort(graph[i].begin(), graph[i].end(), greater<pair<ll, int>>());
        if (graph[i].size() > 1) {
            ans = max(ans, graph[i][0].first + graph[i][1].first + edges[{graph[i][0].second, graph[i][1].second}]);
        }
    }
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7424 KB Output is correct
2 Correct 9 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 9 ms 7424 KB Output is correct
6 Correct 28 ms 10880 KB Output is correct
7 Correct 9 ms 7424 KB Output is correct
8 Correct 9 ms 7424 KB Output is correct
9 Correct 9 ms 7424 KB Output is correct
10 Correct 9 ms 7424 KB Output is correct
11 Correct 10 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 8 ms 7424 KB Output is correct
16 Correct 9 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 11 ms 7808 KB Output is correct
20 Correct 9 ms 7424 KB Output is correct
21 Correct 9 ms 7424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7424 KB Output is correct
2 Correct 9 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 9 ms 7424 KB Output is correct
6 Correct 28 ms 10880 KB Output is correct
7 Correct 9 ms 7424 KB Output is correct
8 Correct 9 ms 7424 KB Output is correct
9 Correct 9 ms 7424 KB Output is correct
10 Correct 9 ms 7424 KB Output is correct
11 Correct 10 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 8 ms 7424 KB Output is correct
16 Correct 9 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 11 ms 7808 KB Output is correct
20 Correct 9 ms 7424 KB Output is correct
21 Correct 9 ms 7424 KB Output is correct
22 Correct 1670 ms 99620 KB Output is correct
23 Correct 615 ms 94708 KB Output is correct
24 Correct 35 ms 11256 KB Output is correct
25 Correct 31 ms 8576 KB Output is correct
26 Correct 16 ms 8576 KB Output is correct
27 Correct 12 ms 7936 KB Output is correct
28 Correct 549 ms 44324 KB Output is correct
29 Correct 151 ms 21752 KB Output is correct
30 Correct 297 ms 29432 KB Output is correct
31 Correct 9 ms 7552 KB Output is correct
32 Correct 9 ms 7552 KB Output is correct
33 Correct 655 ms 97496 KB Output is correct
34 Correct 523 ms 88228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 290 ms 37880 KB Output is correct
2 Correct 818 ms 86008 KB Output is correct
3 Correct 226 ms 33400 KB Output is correct
4 Correct 464 ms 57720 KB Output is correct
5 Correct 1217 ms 76920 KB Output is correct
6 Correct 124 ms 28280 KB Output is correct
7 Correct 304 ms 67960 KB Output is correct
8 Correct 324 ms 66048 KB Output is correct
9 Correct 14 ms 9856 KB Output is correct
10 Correct 132 ms 28408 KB Output is correct
11 Correct 334 ms 65628 KB Output is correct
12 Correct 264 ms 49272 KB Output is correct
13 Correct 9 ms 7424 KB Output is correct
14 Correct 211 ms 25464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 290 ms 37880 KB Output is correct
2 Correct 818 ms 86008 KB Output is correct
3 Correct 226 ms 33400 KB Output is correct
4 Correct 464 ms 57720 KB Output is correct
5 Correct 1217 ms 76920 KB Output is correct
6 Correct 124 ms 28280 KB Output is correct
7 Correct 304 ms 67960 KB Output is correct
8 Correct 324 ms 66048 KB Output is correct
9 Correct 14 ms 9856 KB Output is correct
10 Correct 132 ms 28408 KB Output is correct
11 Correct 334 ms 65628 KB Output is correct
12 Correct 264 ms 49272 KB Output is correct
13 Correct 9 ms 7424 KB Output is correct
14 Correct 211 ms 25464 KB Output is correct
15 Correct 569 ms 46544 KB Output is correct
16 Correct 604 ms 44116 KB Output is correct
17 Correct 623 ms 49328 KB Output is correct
18 Correct 867 ms 59176 KB Output is correct
19 Correct 210 ms 27108 KB Output is correct
20 Correct 886 ms 64636 KB Output is correct
21 Correct 792 ms 88696 KB Output is correct
22 Correct 523 ms 61304 KB Output is correct
23 Correct 627 ms 59828 KB Output is correct
24 Correct 361 ms 36168 KB Output is correct
25 Correct 955 ms 66936 KB Output is correct
26 Correct 849 ms 61220 KB Output is correct
27 Correct 852 ms 58968 KB Output is correct
28 Correct 8 ms 7424 KB Output is correct
29 Correct 9 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 9 ms 7424 KB Output is correct
33 Correct 28 ms 10880 KB Output is correct
34 Correct 9 ms 7424 KB Output is correct
35 Correct 9 ms 7424 KB Output is correct
36 Correct 9 ms 7424 KB Output is correct
37 Correct 9 ms 7424 KB Output is correct
38 Correct 10 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 8 ms 7424 KB Output is correct
43 Correct 9 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 11 ms 7808 KB Output is correct
47 Correct 9 ms 7424 KB Output is correct
48 Correct 9 ms 7424 KB Output is correct
49 Correct 1670 ms 99620 KB Output is correct
50 Correct 615 ms 94708 KB Output is correct
51 Correct 35 ms 11256 KB Output is correct
52 Correct 31 ms 8576 KB Output is correct
53 Correct 16 ms 8576 KB Output is correct
54 Correct 12 ms 7936 KB Output is correct
55 Correct 549 ms 44324 KB Output is correct
56 Correct 151 ms 21752 KB Output is correct
57 Correct 297 ms 29432 KB Output is correct
58 Correct 9 ms 7552 KB Output is correct
59 Correct 9 ms 7552 KB Output is correct
60 Correct 655 ms 97496 KB Output is correct
61 Correct 523 ms 88228 KB Output is correct