#include <bits/stdc++.h>
#define int ll
#define all(v) v.begin(), v.end()
// author : a1abay
using namespace std;
typedef long long ll;
typedef long double ld;
const int sz = 3e5 + 5;
const int inf = 1e9 + 7;
int n, m, ans, u, v, w;
vector<array<int, 2>> g[sz];
map<array<int, 2>, int> e;
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for(int i = 1; i <= m; i++)
{
cin >> u >> v >> w;
g[u].push_back({w, v});
g[v].push_back({w, u});
e[{u, v}] = w;
e[{v, u}] = w;
}
for(int i = 1; i <= n; i++)
{
sort(all(g[i]));
reverse(all(g[i]));
int s = 0;
for(auto p : g[i]) s += p[0];
ans = max(ans, s);
}
for(int i = 1; i <= n; i++)
{
if(g[i].size() < 2) continue;
if(!e[{g[i][0][1], g[i][1][1]}]) continue;
ans = max(ans, g[i][0][0] + g[i][1][0] + e[{g[i][0][1], g[i][1][1]}]);
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
7260 KB |
Output is correct |
2 |
Correct |
2 ms |
7260 KB |
Output is correct |
3 |
Correct |
2 ms |
7256 KB |
Output is correct |
4 |
Correct |
2 ms |
7260 KB |
Output is correct |
5 |
Correct |
2 ms |
7260 KB |
Output is correct |
6 |
Correct |
18 ms |
11056 KB |
Output is correct |
7 |
Correct |
2 ms |
7260 KB |
Output is correct |
8 |
Correct |
2 ms |
7504 KB |
Output is correct |
9 |
Correct |
2 ms |
7516 KB |
Output is correct |
10 |
Correct |
2 ms |
7512 KB |
Output is correct |
11 |
Correct |
2 ms |
7516 KB |
Output is correct |
12 |
Correct |
2 ms |
7516 KB |
Output is correct |
13 |
Correct |
2 ms |
7516 KB |
Output is correct |
14 |
Correct |
2 ms |
7496 KB |
Output is correct |
15 |
Correct |
2 ms |
7260 KB |
Output is correct |
16 |
Correct |
2 ms |
7260 KB |
Output is correct |
17 |
Correct |
2 ms |
7512 KB |
Output is correct |
18 |
Correct |
3 ms |
7516 KB |
Output is correct |
19 |
Correct |
3 ms |
7772 KB |
Output is correct |
20 |
Correct |
2 ms |
7516 KB |
Output is correct |
21 |
Correct |
2 ms |
7260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
7260 KB |
Output is correct |
2 |
Correct |
2 ms |
7260 KB |
Output is correct |
3 |
Correct |
2 ms |
7256 KB |
Output is correct |
4 |
Correct |
2 ms |
7260 KB |
Output is correct |
5 |
Correct |
2 ms |
7260 KB |
Output is correct |
6 |
Correct |
18 ms |
11056 KB |
Output is correct |
7 |
Correct |
2 ms |
7260 KB |
Output is correct |
8 |
Correct |
2 ms |
7504 KB |
Output is correct |
9 |
Correct |
2 ms |
7516 KB |
Output is correct |
10 |
Correct |
2 ms |
7512 KB |
Output is correct |
11 |
Correct |
2 ms |
7516 KB |
Output is correct |
12 |
Correct |
2 ms |
7516 KB |
Output is correct |
13 |
Correct |
2 ms |
7516 KB |
Output is correct |
14 |
Correct |
2 ms |
7496 KB |
Output is correct |
15 |
Correct |
2 ms |
7260 KB |
Output is correct |
16 |
Correct |
2 ms |
7260 KB |
Output is correct |
17 |
Correct |
2 ms |
7512 KB |
Output is correct |
18 |
Correct |
3 ms |
7516 KB |
Output is correct |
19 |
Correct |
3 ms |
7772 KB |
Output is correct |
20 |
Correct |
2 ms |
7516 KB |
Output is correct |
21 |
Correct |
2 ms |
7260 KB |
Output is correct |
22 |
Correct |
1242 ms |
99924 KB |
Output is correct |
23 |
Correct |
462 ms |
95056 KB |
Output is correct |
24 |
Correct |
18 ms |
11356 KB |
Output is correct |
25 |
Correct |
7 ms |
8536 KB |
Output is correct |
26 |
Correct |
6 ms |
8540 KB |
Output is correct |
27 |
Correct |
4 ms |
8028 KB |
Output is correct |
28 |
Correct |
330 ms |
44224 KB |
Output is correct |
29 |
Correct |
85 ms |
22100 KB |
Output is correct |
30 |
Correct |
168 ms |
29268 KB |
Output is correct |
31 |
Correct |
3 ms |
7516 KB |
Output is correct |
32 |
Correct |
2 ms |
7516 KB |
Output is correct |
33 |
Correct |
496 ms |
97340 KB |
Output is correct |
34 |
Correct |
387 ms |
87644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
222 ms |
37884 KB |
Output is correct |
2 |
Correct |
575 ms |
83484 KB |
Output is correct |
3 |
Correct |
155 ms |
32892 KB |
Output is correct |
4 |
Correct |
354 ms |
56180 KB |
Output is correct |
5 |
Correct |
894 ms |
74940 KB |
Output is correct |
6 |
Correct |
86 ms |
28368 KB |
Output is correct |
7 |
Correct |
214 ms |
65932 KB |
Output is correct |
8 |
Correct |
248 ms |
63608 KB |
Output is correct |
9 |
Correct |
4 ms |
7512 KB |
Output is correct |
10 |
Correct |
87 ms |
28240 KB |
Output is correct |
11 |
Correct |
250 ms |
66052 KB |
Output is correct |
12 |
Correct |
224 ms |
49148 KB |
Output is correct |
13 |
Correct |
2 ms |
7260 KB |
Output is correct |
14 |
Correct |
126 ms |
25280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
222 ms |
37884 KB |
Output is correct |
2 |
Correct |
575 ms |
83484 KB |
Output is correct |
3 |
Correct |
155 ms |
32892 KB |
Output is correct |
4 |
Correct |
354 ms |
56180 KB |
Output is correct |
5 |
Correct |
894 ms |
74940 KB |
Output is correct |
6 |
Correct |
86 ms |
28368 KB |
Output is correct |
7 |
Correct |
214 ms |
65932 KB |
Output is correct |
8 |
Correct |
248 ms |
63608 KB |
Output is correct |
9 |
Correct |
4 ms |
7512 KB |
Output is correct |
10 |
Correct |
87 ms |
28240 KB |
Output is correct |
11 |
Correct |
250 ms |
66052 KB |
Output is correct |
12 |
Correct |
224 ms |
49148 KB |
Output is correct |
13 |
Correct |
2 ms |
7260 KB |
Output is correct |
14 |
Correct |
126 ms |
25280 KB |
Output is correct |
15 |
Correct |
2 ms |
7260 KB |
Output is correct |
16 |
Correct |
2 ms |
7260 KB |
Output is correct |
17 |
Correct |
2 ms |
7256 KB |
Output is correct |
18 |
Correct |
2 ms |
7260 KB |
Output is correct |
19 |
Correct |
2 ms |
7260 KB |
Output is correct |
20 |
Correct |
18 ms |
11056 KB |
Output is correct |
21 |
Correct |
2 ms |
7260 KB |
Output is correct |
22 |
Correct |
2 ms |
7504 KB |
Output is correct |
23 |
Correct |
2 ms |
7516 KB |
Output is correct |
24 |
Correct |
2 ms |
7512 KB |
Output is correct |
25 |
Correct |
2 ms |
7516 KB |
Output is correct |
26 |
Correct |
2 ms |
7516 KB |
Output is correct |
27 |
Correct |
2 ms |
7516 KB |
Output is correct |
28 |
Correct |
2 ms |
7496 KB |
Output is correct |
29 |
Correct |
2 ms |
7260 KB |
Output is correct |
30 |
Correct |
2 ms |
7260 KB |
Output is correct |
31 |
Correct |
2 ms |
7512 KB |
Output is correct |
32 |
Correct |
3 ms |
7516 KB |
Output is correct |
33 |
Correct |
3 ms |
7772 KB |
Output is correct |
34 |
Correct |
2 ms |
7516 KB |
Output is correct |
35 |
Correct |
2 ms |
7260 KB |
Output is correct |
36 |
Correct |
1242 ms |
99924 KB |
Output is correct |
37 |
Correct |
462 ms |
95056 KB |
Output is correct |
38 |
Correct |
18 ms |
11356 KB |
Output is correct |
39 |
Correct |
7 ms |
8536 KB |
Output is correct |
40 |
Correct |
6 ms |
8540 KB |
Output is correct |
41 |
Correct |
4 ms |
8028 KB |
Output is correct |
42 |
Correct |
330 ms |
44224 KB |
Output is correct |
43 |
Correct |
85 ms |
22100 KB |
Output is correct |
44 |
Correct |
168 ms |
29268 KB |
Output is correct |
45 |
Correct |
3 ms |
7516 KB |
Output is correct |
46 |
Correct |
2 ms |
7516 KB |
Output is correct |
47 |
Correct |
496 ms |
97340 KB |
Output is correct |
48 |
Correct |
387 ms |
87644 KB |
Output is correct |
49 |
Correct |
335 ms |
45796 KB |
Output is correct |
50 |
Correct |
342 ms |
43956 KB |
Output is correct |
51 |
Correct |
450 ms |
48456 KB |
Output is correct |
52 |
Correct |
633 ms |
59188 KB |
Output is correct |
53 |
Correct |
122 ms |
26420 KB |
Output is correct |
54 |
Correct |
606 ms |
64692 KB |
Output is correct |
55 |
Correct |
615 ms |
86356 KB |
Output is correct |
56 |
Correct |
350 ms |
59732 KB |
Output is correct |
57 |
Correct |
418 ms |
57784 KB |
Output is correct |
58 |
Correct |
225 ms |
35496 KB |
Output is correct |
59 |
Correct |
628 ms |
66212 KB |
Output is correct |
60 |
Correct |
542 ms |
60624 KB |
Output is correct |
61 |
Correct |
569 ms |
58448 KB |
Output is correct |