#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll maxN = 5e5+10;
ll n, m;
ll v[maxN];
vector<ll> adj[maxN];
map<pair<ll, ll>, ll> a;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(nullptr);
for(ll i = 0; i < maxN; i++)v[i]=0;
cin>>n>>m;
for(ll i = 0; i < m; i++){
ll aa, bb, cc;
cin>>aa>>bb>>cc;
v[aa]+=cc;
v[bb]+=cc;
adj[aa].push_back(bb);
adj[bb].push_back(aa);
a[{aa, bb}]=cc;
a[{bb, aa}]=cc;
}
ll res=0;
for(ll i = 1; i <= n; i++){
res=max(res, v[i]);
for(ll x = 0; x < ((ll)(adj[i].size()))-1; x++){
ll vv=adj[i][x], vvv=adj[i][x+1];
if(a.count({vv, vvv})){
res=max(res, a[{i, vv}]+a[{i, vvv}]+a[{vv, vvv}]);
}
}
}
cout<<res;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
15864 KB |
Output is correct |
2 |
Correct |
8 ms |
15956 KB |
Output is correct |
3 |
Correct |
8 ms |
15956 KB |
Output is correct |
4 |
Correct |
8 ms |
15956 KB |
Output is correct |
5 |
Correct |
8 ms |
15956 KB |
Output is correct |
6 |
Correct |
34 ms |
18800 KB |
Output is correct |
7 |
Correct |
8 ms |
15956 KB |
Output is correct |
8 |
Correct |
8 ms |
15896 KB |
Output is correct |
9 |
Correct |
9 ms |
16044 KB |
Output is correct |
10 |
Correct |
11 ms |
15956 KB |
Output is correct |
11 |
Correct |
10 ms |
15956 KB |
Output is correct |
12 |
Correct |
9 ms |
15956 KB |
Output is correct |
13 |
Correct |
9 ms |
15988 KB |
Output is correct |
14 |
Correct |
9 ms |
15956 KB |
Output is correct |
15 |
Correct |
8 ms |
15956 KB |
Output is correct |
16 |
Correct |
8 ms |
15956 KB |
Output is correct |
17 |
Correct |
8 ms |
15956 KB |
Output is correct |
18 |
Correct |
9 ms |
16064 KB |
Output is correct |
19 |
Correct |
10 ms |
16212 KB |
Output is correct |
20 |
Correct |
8 ms |
15956 KB |
Output is correct |
21 |
Correct |
8 ms |
15984 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
15864 KB |
Output is correct |
2 |
Correct |
8 ms |
15956 KB |
Output is correct |
3 |
Correct |
8 ms |
15956 KB |
Output is correct |
4 |
Correct |
8 ms |
15956 KB |
Output is correct |
5 |
Correct |
8 ms |
15956 KB |
Output is correct |
6 |
Correct |
34 ms |
18800 KB |
Output is correct |
7 |
Correct |
8 ms |
15956 KB |
Output is correct |
8 |
Correct |
8 ms |
15896 KB |
Output is correct |
9 |
Correct |
9 ms |
16044 KB |
Output is correct |
10 |
Correct |
11 ms |
15956 KB |
Output is correct |
11 |
Correct |
10 ms |
15956 KB |
Output is correct |
12 |
Correct |
9 ms |
15956 KB |
Output is correct |
13 |
Correct |
9 ms |
15988 KB |
Output is correct |
14 |
Correct |
9 ms |
15956 KB |
Output is correct |
15 |
Correct |
8 ms |
15956 KB |
Output is correct |
16 |
Correct |
8 ms |
15956 KB |
Output is correct |
17 |
Correct |
8 ms |
15956 KB |
Output is correct |
18 |
Correct |
9 ms |
16064 KB |
Output is correct |
19 |
Correct |
10 ms |
16212 KB |
Output is correct |
20 |
Correct |
8 ms |
15956 KB |
Output is correct |
21 |
Correct |
8 ms |
15984 KB |
Output is correct |
22 |
Correct |
2072 ms |
97696 KB |
Output is correct |
23 |
Correct |
986 ms |
95412 KB |
Output is correct |
24 |
Correct |
35 ms |
19236 KB |
Output is correct |
25 |
Correct |
14 ms |
17020 KB |
Output is correct |
26 |
Correct |
18 ms |
16972 KB |
Output is correct |
27 |
Correct |
13 ms |
16412 KB |
Output is correct |
28 |
Correct |
527 ms |
48636 KB |
Output is correct |
29 |
Correct |
296 ms |
28712 KB |
Output is correct |
30 |
Correct |
434 ms |
35772 KB |
Output is correct |
31 |
Correct |
9 ms |
16084 KB |
Output is correct |
32 |
Correct |
11 ms |
15992 KB |
Output is correct |
33 |
Correct |
656 ms |
95412 KB |
Output is correct |
34 |
Correct |
589 ms |
86988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
247 ms |
44032 KB |
Output is correct |
2 |
Correct |
588 ms |
62892 KB |
Output is correct |
3 |
Correct |
201 ms |
31632 KB |
Output is correct |
4 |
Correct |
345 ms |
49276 KB |
Output is correct |
5 |
Correct |
1144 ms |
67816 KB |
Output is correct |
6 |
Correct |
213 ms |
34880 KB |
Output is correct |
7 |
Correct |
245 ms |
59976 KB |
Output is correct |
8 |
Correct |
354 ms |
67296 KB |
Output is correct |
9 |
Correct |
10 ms |
16124 KB |
Output is correct |
10 |
Correct |
241 ms |
34912 KB |
Output is correct |
11 |
Correct |
301 ms |
63504 KB |
Output is correct |
12 |
Correct |
324 ms |
53820 KB |
Output is correct |
13 |
Correct |
8 ms |
15956 KB |
Output is correct |
14 |
Correct |
221 ms |
31684 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
247 ms |
44032 KB |
Output is correct |
2 |
Correct |
588 ms |
62892 KB |
Output is correct |
3 |
Correct |
201 ms |
31632 KB |
Output is correct |
4 |
Correct |
345 ms |
49276 KB |
Output is correct |
5 |
Correct |
1144 ms |
67816 KB |
Output is correct |
6 |
Correct |
213 ms |
34880 KB |
Output is correct |
7 |
Correct |
245 ms |
59976 KB |
Output is correct |
8 |
Correct |
354 ms |
67296 KB |
Output is correct |
9 |
Correct |
10 ms |
16124 KB |
Output is correct |
10 |
Correct |
241 ms |
34912 KB |
Output is correct |
11 |
Correct |
301 ms |
63504 KB |
Output is correct |
12 |
Correct |
324 ms |
53820 KB |
Output is correct |
13 |
Correct |
8 ms |
15956 KB |
Output is correct |
14 |
Correct |
221 ms |
31684 KB |
Output is correct |
15 |
Correct |
7 ms |
15864 KB |
Output is correct |
16 |
Correct |
8 ms |
15956 KB |
Output is correct |
17 |
Correct |
8 ms |
15956 KB |
Output is correct |
18 |
Correct |
8 ms |
15956 KB |
Output is correct |
19 |
Correct |
8 ms |
15956 KB |
Output is correct |
20 |
Correct |
34 ms |
18800 KB |
Output is correct |
21 |
Correct |
8 ms |
15956 KB |
Output is correct |
22 |
Correct |
8 ms |
15896 KB |
Output is correct |
23 |
Correct |
9 ms |
16044 KB |
Output is correct |
24 |
Correct |
11 ms |
15956 KB |
Output is correct |
25 |
Correct |
10 ms |
15956 KB |
Output is correct |
26 |
Correct |
9 ms |
15956 KB |
Output is correct |
27 |
Correct |
9 ms |
15988 KB |
Output is correct |
28 |
Correct |
9 ms |
15956 KB |
Output is correct |
29 |
Correct |
8 ms |
15956 KB |
Output is correct |
30 |
Correct |
8 ms |
15956 KB |
Output is correct |
31 |
Correct |
8 ms |
15956 KB |
Output is correct |
32 |
Correct |
9 ms |
16064 KB |
Output is correct |
33 |
Correct |
10 ms |
16212 KB |
Output is correct |
34 |
Correct |
8 ms |
15956 KB |
Output is correct |
35 |
Correct |
8 ms |
15984 KB |
Output is correct |
36 |
Correct |
2072 ms |
97696 KB |
Output is correct |
37 |
Correct |
986 ms |
95412 KB |
Output is correct |
38 |
Correct |
35 ms |
19236 KB |
Output is correct |
39 |
Correct |
14 ms |
17020 KB |
Output is correct |
40 |
Correct |
18 ms |
16972 KB |
Output is correct |
41 |
Correct |
13 ms |
16412 KB |
Output is correct |
42 |
Correct |
527 ms |
48636 KB |
Output is correct |
43 |
Correct |
296 ms |
28712 KB |
Output is correct |
44 |
Correct |
434 ms |
35772 KB |
Output is correct |
45 |
Correct |
9 ms |
16084 KB |
Output is correct |
46 |
Correct |
11 ms |
15992 KB |
Output is correct |
47 |
Correct |
656 ms |
95412 KB |
Output is correct |
48 |
Correct |
589 ms |
86988 KB |
Output is correct |
49 |
Correct |
613 ms |
49824 KB |
Output is correct |
50 |
Correct |
473 ms |
48756 KB |
Output is correct |
51 |
Correct |
727 ms |
54076 KB |
Output is correct |
52 |
Correct |
1004 ms |
62524 KB |
Output is correct |
53 |
Correct |
201 ms |
34088 KB |
Output is correct |
54 |
Correct |
1070 ms |
67188 KB |
Output is correct |
55 |
Correct |
627 ms |
70200 KB |
Output is correct |
56 |
Correct |
394 ms |
51640 KB |
Output is correct |
57 |
Correct |
568 ms |
60804 KB |
Output is correct |
58 |
Correct |
375 ms |
40912 KB |
Output is correct |
59 |
Correct |
1018 ms |
65480 KB |
Output is correct |
60 |
Correct |
952 ms |
63732 KB |
Output is correct |
61 |
Correct |
1018 ms |
61732 KB |
Output is correct |