# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
243220 | 2020-06-30T14:57:43 Z | Nightlight | Cheap flights (LMIO18_pigus_skrydziai) | C++14 | 526 ms | 32180 KB |
#include <bits/stdc++.h> #define pii pair<int, int> #define piii tuple<int, int, int> using namespace std; int N, M; vector<pii> adj[300005]; int deg[300005]; long long res[300005]; piii edge[300005]; int vis[300005]; long long ada[300005]; long long ans; bool comp(int a, int b) { return deg[a] == deg[b] ? a > b : deg[a] > deg[b]; } int main() { scanf("%d %d", &N, &M); int u, v, w; for(int i = 1; i <= M; i++) { scanf("%d %d %d", &u, &v, &w); deg[u]++, deg[v]++; ada[u] += w, ada[v] += w; edge[i] = make_tuple(u, v, w); } for(int i = 1; i <= M; i++) { tie(u, v, w) = edge[i]; if(comp(u, v)) adj[u].emplace_back(v, w); else adj[v].emplace_back(u, w); } for(int u = 1; u <= N; u++) { ans = max(ans, ada[u]); for(pii v : adj[u]) { vis[v.first] = v.second; } for(pii v : adj[u]) { for(pii w : adj[v.first]) { if(vis[w.first]) { ans = max(ans, (long long) vis[v.first] + vis[w.first] + w.second); } } } for(pii v : adj[u]) { vis[v.first] = 0; } } printf("%lld\n", ans); cin >> N; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 7424 KB | Output is correct |
2 | Correct | 11 ms | 7424 KB | Output is correct |
3 | Correct | 10 ms | 7424 KB | Output is correct |
4 | Correct | 9 ms | 7424 KB | Output is correct |
5 | Correct | 12 ms | 7424 KB | Output is correct |
6 | Correct | 20 ms | 8064 KB | Output is correct |
7 | Correct | 10 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 | 7424 KB | Output is correct |
12 | Correct | 9 ms | 7424 KB | Output is correct |
13 | Correct | 9 ms | 7424 KB | Output is correct |
14 | Correct | 9 ms | 7424 KB | Output is correct |
15 | Correct | 9 ms | 7424 KB | Output is correct |
16 | Correct | 9 ms | 7424 KB | Output is correct |
17 | Correct | 9 ms | 7328 KB | Output is correct |
18 | Correct | 11 ms | 7424 KB | Output is correct |
19 | Correct | 10 ms | 7424 KB | Output is correct |
20 | Correct | 10 ms | 7424 KB | Output is correct |
21 | Correct | 11 ms | 7432 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 7424 KB | Output is correct |
2 | Correct | 11 ms | 7424 KB | Output is correct |
3 | Correct | 10 ms | 7424 KB | Output is correct |
4 | Correct | 9 ms | 7424 KB | Output is correct |
5 | Correct | 12 ms | 7424 KB | Output is correct |
6 | Correct | 20 ms | 8064 KB | Output is correct |
7 | Correct | 10 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 | 7424 KB | Output is correct |
12 | Correct | 9 ms | 7424 KB | Output is correct |
13 | Correct | 9 ms | 7424 KB | Output is correct |
14 | Correct | 9 ms | 7424 KB | Output is correct |
15 | Correct | 9 ms | 7424 KB | Output is correct |
16 | Correct | 9 ms | 7424 KB | Output is correct |
17 | Correct | 9 ms | 7328 KB | Output is correct |
18 | Correct | 11 ms | 7424 KB | Output is correct |
19 | Correct | 10 ms | 7424 KB | Output is correct |
20 | Correct | 10 ms | 7424 KB | Output is correct |
21 | Correct | 11 ms | 7432 KB | Output is correct |
22 | Correct | 318 ms | 28112 KB | Output is correct |
23 | Correct | 526 ms | 27360 KB | Output is correct |
24 | Correct | 18 ms | 8192 KB | Output is correct |
25 | Correct | 12 ms | 7680 KB | Output is correct |
26 | Correct | 12 ms | 7680 KB | Output is correct |
27 | Correct | 11 ms | 7552 KB | Output is correct |
28 | Correct | 121 ms | 15352 KB | Output is correct |
29 | Correct | 60 ms | 10616 KB | Output is correct |
30 | Correct | 101 ms | 12408 KB | Output is correct |
31 | Correct | 10 ms | 7424 KB | Output is correct |
32 | Correct | 11 ms | 7424 KB | Output is correct |
33 | Correct | 194 ms | 26744 KB | Output is correct |
34 | Correct | 158 ms | 23508 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 104 ms | 20728 KB | Output is correct |
2 | Correct | 267 ms | 27564 KB | Output is correct |
3 | Correct | 59 ms | 13944 KB | Output is correct |
4 | Correct | 151 ms | 21496 KB | Output is correct |
5 | Correct | 219 ms | 23672 KB | Output is correct |
6 | Correct | 83 ms | 11388 KB | Output is correct |
7 | Correct | 113 ms | 25336 KB | Output is correct |
8 | Correct | 130 ms | 26360 KB | Output is correct |
9 | Correct | 13 ms | 11904 KB | Output is correct |
10 | Correct | 84 ms | 11384 KB | Output is correct |
11 | Correct | 105 ms | 19948 KB | Output is correct |
12 | Correct | 92 ms | 14712 KB | Output is correct |
13 | Correct | 9 ms | 7424 KB | Output is correct |
14 | Correct | 55 ms | 10872 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 104 ms | 20728 KB | Output is correct |
2 | Correct | 267 ms | 27564 KB | Output is correct |
3 | Correct | 59 ms | 13944 KB | Output is correct |
4 | Correct | 151 ms | 21496 KB | Output is correct |
5 | Correct | 219 ms | 23672 KB | Output is correct |
6 | Correct | 83 ms | 11388 KB | Output is correct |
7 | Correct | 113 ms | 25336 KB | Output is correct |
8 | Correct | 130 ms | 26360 KB | Output is correct |
9 | Correct | 13 ms | 11904 KB | Output is correct |
10 | Correct | 84 ms | 11384 KB | Output is correct |
11 | Correct | 105 ms | 19948 KB | Output is correct |
12 | Correct | 92 ms | 14712 KB | Output is correct |
13 | Correct | 9 ms | 7424 KB | Output is correct |
14 | Correct | 55 ms | 10872 KB | Output is correct |
15 | Correct | 86 ms | 15468 KB | Output is correct |
16 | Correct | 92 ms | 15484 KB | Output is correct |
17 | Correct | 154 ms | 17900 KB | Output is correct |
18 | Correct | 174 ms | 19032 KB | Output is correct |
19 | Correct | 56 ms | 12908 KB | Output is correct |
20 | Correct | 146 ms | 18680 KB | Output is correct |
21 | Correct | 279 ms | 32180 KB | Output is correct |
22 | Correct | 154 ms | 23672 KB | Output is correct |
23 | Correct | 125 ms | 21608 KB | Output is correct |
24 | Correct | 63 ms | 12776 KB | Output is correct |
25 | Correct | 159 ms | 20576 KB | Output is correct |
26 | Correct | 118 ms | 17176 KB | Output is correct |
27 | Correct | 127 ms | 17400 KB | Output is correct |
28 | Correct | 11 ms | 7424 KB | Output is correct |
29 | Correct | 11 ms | 7424 KB | Output is correct |
30 | Correct | 10 ms | 7424 KB | Output is correct |
31 | Correct | 9 ms | 7424 KB | Output is correct |
32 | Correct | 12 ms | 7424 KB | Output is correct |
33 | Correct | 20 ms | 8064 KB | Output is correct |
34 | Correct | 10 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 | 7424 KB | Output is correct |
39 | Correct | 9 ms | 7424 KB | Output is correct |
40 | Correct | 9 ms | 7424 KB | Output is correct |
41 | Correct | 9 ms | 7424 KB | Output is correct |
42 | Correct | 9 ms | 7424 KB | Output is correct |
43 | Correct | 9 ms | 7424 KB | Output is correct |
44 | Correct | 9 ms | 7328 KB | Output is correct |
45 | Correct | 11 ms | 7424 KB | Output is correct |
46 | Correct | 10 ms | 7424 KB | Output is correct |
47 | Correct | 10 ms | 7424 KB | Output is correct |
48 | Correct | 11 ms | 7432 KB | Output is correct |
49 | Correct | 318 ms | 28112 KB | Output is correct |
50 | Correct | 526 ms | 27360 KB | Output is correct |
51 | Correct | 18 ms | 8192 KB | Output is correct |
52 | Correct | 12 ms | 7680 KB | Output is correct |
53 | Correct | 12 ms | 7680 KB | Output is correct |
54 | Correct | 11 ms | 7552 KB | Output is correct |
55 | Correct | 121 ms | 15352 KB | Output is correct |
56 | Correct | 60 ms | 10616 KB | Output is correct |
57 | Correct | 101 ms | 12408 KB | Output is correct |
58 | Correct | 10 ms | 7424 KB | Output is correct |
59 | Correct | 11 ms | 7424 KB | Output is correct |
60 | Correct | 194 ms | 26744 KB | Output is correct |
61 | Correct | 158 ms | 23508 KB | Output is correct |