#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5+7;
long long t[MAXN];
vector<pair<int,int> > v;
vector<pair<long long,int> >g[MAXN];
map<pair<int,int>,long long>w;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n,m,a,b,c,s;
long long res=0;
cin>>n>>m;
for(int i=1;i<=m;i++){
cin>>a>>b>>c;
t[a]+=c; t[b]+=c;
g[a].push_back({c,b}); g[b].push_back({c,a});
v.push_back({a,b});
w[{a,b}]=w[{b,a}]=c;
}
for(int i=1;i<=n;i++){
res=max(res,t[i]);
}
for(int i=1;i<=n;i++){
sort(g[i].begin(),g[i].end());
s=g[i].size();
if(g[i].size()>1) {
res=max(res,g[i][s-1].first + g[i][s-2].first + w[{g[i][s-1].second,g[i][s-2].second}]);
}
}
cout<<res<<'\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
12888 KB |
Output is correct |
2 |
Correct |
3 ms |
12888 KB |
Output is correct |
3 |
Correct |
2 ms |
12892 KB |
Output is correct |
4 |
Correct |
3 ms |
12948 KB |
Output is correct |
5 |
Correct |
3 ms |
12892 KB |
Output is correct |
6 |
Correct |
14 ms |
16432 KB |
Output is correct |
7 |
Correct |
3 ms |
12892 KB |
Output is correct |
8 |
Correct |
3 ms |
12888 KB |
Output is correct |
9 |
Correct |
3 ms |
12892 KB |
Output is correct |
10 |
Correct |
3 ms |
12968 KB |
Output is correct |
11 |
Correct |
3 ms |
12892 KB |
Output is correct |
12 |
Correct |
3 ms |
12892 KB |
Output is correct |
13 |
Correct |
3 ms |
12892 KB |
Output is correct |
14 |
Correct |
3 ms |
12892 KB |
Output is correct |
15 |
Correct |
3 ms |
12892 KB |
Output is correct |
16 |
Correct |
3 ms |
12892 KB |
Output is correct |
17 |
Correct |
4 ms |
12892 KB |
Output is correct |
18 |
Correct |
3 ms |
13148 KB |
Output is correct |
19 |
Correct |
6 ms |
13148 KB |
Output is correct |
20 |
Correct |
3 ms |
12888 KB |
Output is correct |
21 |
Correct |
3 ms |
12892 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
12888 KB |
Output is correct |
2 |
Correct |
3 ms |
12888 KB |
Output is correct |
3 |
Correct |
2 ms |
12892 KB |
Output is correct |
4 |
Correct |
3 ms |
12948 KB |
Output is correct |
5 |
Correct |
3 ms |
12892 KB |
Output is correct |
6 |
Correct |
14 ms |
16432 KB |
Output is correct |
7 |
Correct |
3 ms |
12892 KB |
Output is correct |
8 |
Correct |
3 ms |
12888 KB |
Output is correct |
9 |
Correct |
3 ms |
12892 KB |
Output is correct |
10 |
Correct |
3 ms |
12968 KB |
Output is correct |
11 |
Correct |
3 ms |
12892 KB |
Output is correct |
12 |
Correct |
3 ms |
12892 KB |
Output is correct |
13 |
Correct |
3 ms |
12892 KB |
Output is correct |
14 |
Correct |
3 ms |
12892 KB |
Output is correct |
15 |
Correct |
3 ms |
12892 KB |
Output is correct |
16 |
Correct |
3 ms |
12892 KB |
Output is correct |
17 |
Correct |
4 ms |
12892 KB |
Output is correct |
18 |
Correct |
3 ms |
13148 KB |
Output is correct |
19 |
Correct |
6 ms |
13148 KB |
Output is correct |
20 |
Correct |
3 ms |
12888 KB |
Output is correct |
21 |
Correct |
3 ms |
12892 KB |
Output is correct |
22 |
Correct |
1351 ms |
100164 KB |
Output is correct |
23 |
Correct |
429 ms |
104120 KB |
Output is correct |
24 |
Correct |
19 ms |
16856 KB |
Output is correct |
25 |
Correct |
7 ms |
14172 KB |
Output is correct |
26 |
Correct |
7 ms |
14200 KB |
Output is correct |
27 |
Correct |
5 ms |
13404 KB |
Output is correct |
28 |
Correct |
374 ms |
51732 KB |
Output is correct |
29 |
Correct |
88 ms |
27680 KB |
Output is correct |
30 |
Correct |
165 ms |
35560 KB |
Output is correct |
31 |
Correct |
3 ms |
12888 KB |
Output is correct |
32 |
Correct |
3 ms |
12892 KB |
Output is correct |
33 |
Correct |
458 ms |
106560 KB |
Output is correct |
34 |
Correct |
380 ms |
97208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
209 ms |
44112 KB |
Output is correct |
2 |
Correct |
613 ms |
89012 KB |
Output is correct |
3 |
Correct |
177 ms |
39652 KB |
Output is correct |
4 |
Correct |
320 ms |
62400 KB |
Output is correct |
5 |
Correct |
972 ms |
80484 KB |
Output is correct |
6 |
Correct |
101 ms |
33732 KB |
Output is correct |
7 |
Correct |
193 ms |
71684 KB |
Output is correct |
8 |
Correct |
210 ms |
69308 KB |
Output is correct |
9 |
Correct |
5 ms |
15192 KB |
Output is correct |
10 |
Correct |
92 ms |
33504 KB |
Output is correct |
11 |
Correct |
232 ms |
73456 KB |
Output is correct |
12 |
Correct |
196 ms |
54224 KB |
Output is correct |
13 |
Correct |
3 ms |
12888 KB |
Output is correct |
14 |
Correct |
125 ms |
30404 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
209 ms |
44112 KB |
Output is correct |
2 |
Correct |
613 ms |
89012 KB |
Output is correct |
3 |
Correct |
177 ms |
39652 KB |
Output is correct |
4 |
Correct |
320 ms |
62400 KB |
Output is correct |
5 |
Correct |
972 ms |
80484 KB |
Output is correct |
6 |
Correct |
101 ms |
33732 KB |
Output is correct |
7 |
Correct |
193 ms |
71684 KB |
Output is correct |
8 |
Correct |
210 ms |
69308 KB |
Output is correct |
9 |
Correct |
5 ms |
15192 KB |
Output is correct |
10 |
Correct |
92 ms |
33504 KB |
Output is correct |
11 |
Correct |
232 ms |
73456 KB |
Output is correct |
12 |
Correct |
196 ms |
54224 KB |
Output is correct |
13 |
Correct |
3 ms |
12888 KB |
Output is correct |
14 |
Correct |
125 ms |
30404 KB |
Output is correct |
15 |
Correct |
3 ms |
12888 KB |
Output is correct |
16 |
Correct |
3 ms |
12888 KB |
Output is correct |
17 |
Correct |
2 ms |
12892 KB |
Output is correct |
18 |
Correct |
3 ms |
12948 KB |
Output is correct |
19 |
Correct |
3 ms |
12892 KB |
Output is correct |
20 |
Correct |
14 ms |
16432 KB |
Output is correct |
21 |
Correct |
3 ms |
12892 KB |
Output is correct |
22 |
Correct |
3 ms |
12888 KB |
Output is correct |
23 |
Correct |
3 ms |
12892 KB |
Output is correct |
24 |
Correct |
3 ms |
12968 KB |
Output is correct |
25 |
Correct |
3 ms |
12892 KB |
Output is correct |
26 |
Correct |
3 ms |
12892 KB |
Output is correct |
27 |
Correct |
3 ms |
12892 KB |
Output is correct |
28 |
Correct |
3 ms |
12892 KB |
Output is correct |
29 |
Correct |
3 ms |
12892 KB |
Output is correct |
30 |
Correct |
3 ms |
12892 KB |
Output is correct |
31 |
Correct |
4 ms |
12892 KB |
Output is correct |
32 |
Correct |
3 ms |
13148 KB |
Output is correct |
33 |
Correct |
6 ms |
13148 KB |
Output is correct |
34 |
Correct |
3 ms |
12888 KB |
Output is correct |
35 |
Correct |
3 ms |
12892 KB |
Output is correct |
36 |
Correct |
1351 ms |
100164 KB |
Output is correct |
37 |
Correct |
429 ms |
104120 KB |
Output is correct |
38 |
Correct |
19 ms |
16856 KB |
Output is correct |
39 |
Correct |
7 ms |
14172 KB |
Output is correct |
40 |
Correct |
7 ms |
14200 KB |
Output is correct |
41 |
Correct |
5 ms |
13404 KB |
Output is correct |
42 |
Correct |
374 ms |
51732 KB |
Output is correct |
43 |
Correct |
88 ms |
27680 KB |
Output is correct |
44 |
Correct |
165 ms |
35560 KB |
Output is correct |
45 |
Correct |
3 ms |
12888 KB |
Output is correct |
46 |
Correct |
3 ms |
12892 KB |
Output is correct |
47 |
Correct |
458 ms |
106560 KB |
Output is correct |
48 |
Correct |
380 ms |
97208 KB |
Output is correct |
49 |
Correct |
382 ms |
52936 KB |
Output is correct |
50 |
Correct |
389 ms |
51148 KB |
Output is correct |
51 |
Correct |
418 ms |
57720 KB |
Output is correct |
52 |
Correct |
646 ms |
66512 KB |
Output is correct |
53 |
Correct |
122 ms |
34608 KB |
Output is correct |
54 |
Correct |
675 ms |
73912 KB |
Output is correct |
55 |
Correct |
633 ms |
97068 KB |
Output is correct |
56 |
Correct |
357 ms |
68800 KB |
Output is correct |
57 |
Correct |
422 ms |
67368 KB |
Output is correct |
58 |
Correct |
289 ms |
42144 KB |
Output is correct |
59 |
Correct |
658 ms |
75524 KB |
Output is correct |
60 |
Correct |
734 ms |
68684 KB |
Output is correct |
61 |
Correct |
613 ms |
67088 KB |
Output is correct |