#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());
if (g[i].size()>1) {
res=max(res,g[i][0].first + g[i][1].first + w[{g[i][0].second,g[i][1].second}]);
}
}
cout<<res<<'\n';
return 0;
}
Compilation message
pigus_skrydziai.cpp: In function 'int main()':
pigus_skrydziai.cpp:10:16: warning: unused variable 's' [-Wunused-variable]
10 | int n,m,a,b,c,s;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
12888 KB |
Output is correct |
2 |
Correct |
2 ms |
12892 KB |
Output is correct |
3 |
Correct |
3 ms |
12892 KB |
Output is correct |
4 |
Correct |
3 ms |
12892 KB |
Output is correct |
5 |
Correct |
2 ms |
12892 KB |
Output is correct |
6 |
Correct |
14 ms |
16340 KB |
Output is correct |
7 |
Correct |
3 ms |
12892 KB |
Output is correct |
8 |
Correct |
3 ms |
12892 KB |
Output is correct |
9 |
Correct |
3 ms |
12892 KB |
Output is correct |
10 |
Incorrect |
4 ms |
12892 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
12888 KB |
Output is correct |
2 |
Correct |
2 ms |
12892 KB |
Output is correct |
3 |
Correct |
3 ms |
12892 KB |
Output is correct |
4 |
Correct |
3 ms |
12892 KB |
Output is correct |
5 |
Correct |
2 ms |
12892 KB |
Output is correct |
6 |
Correct |
14 ms |
16340 KB |
Output is correct |
7 |
Correct |
3 ms |
12892 KB |
Output is correct |
8 |
Correct |
3 ms |
12892 KB |
Output is correct |
9 |
Correct |
3 ms |
12892 KB |
Output is correct |
10 |
Incorrect |
4 ms |
12892 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
199 ms |
44212 KB |
Output is correct |
2 |
Correct |
573 ms |
89984 KB |
Output is correct |
3 |
Correct |
129 ms |
39624 KB |
Output is correct |
4 |
Correct |
309 ms |
62184 KB |
Output is correct |
5 |
Correct |
834 ms |
80592 KB |
Output is correct |
6 |
Correct |
78 ms |
33472 KB |
Output is correct |
7 |
Correct |
192 ms |
75496 KB |
Output is correct |
8 |
Correct |
209 ms |
73768 KB |
Output is correct |
9 |
Correct |
4 ms |
15196 KB |
Output is correct |
10 |
Correct |
80 ms |
34684 KB |
Output is correct |
11 |
Correct |
224 ms |
77488 KB |
Output is correct |
12 |
Correct |
197 ms |
56772 KB |
Output is correct |
13 |
Correct |
3 ms |
12892 KB |
Output is correct |
14 |
Correct |
116 ms |
31460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
199 ms |
44212 KB |
Output is correct |
2 |
Correct |
573 ms |
89984 KB |
Output is correct |
3 |
Correct |
129 ms |
39624 KB |
Output is correct |
4 |
Correct |
309 ms |
62184 KB |
Output is correct |
5 |
Correct |
834 ms |
80592 KB |
Output is correct |
6 |
Correct |
78 ms |
33472 KB |
Output is correct |
7 |
Correct |
192 ms |
75496 KB |
Output is correct |
8 |
Correct |
209 ms |
73768 KB |
Output is correct |
9 |
Correct |
4 ms |
15196 KB |
Output is correct |
10 |
Correct |
80 ms |
34684 KB |
Output is correct |
11 |
Correct |
224 ms |
77488 KB |
Output is correct |
12 |
Correct |
197 ms |
56772 KB |
Output is correct |
13 |
Correct |
3 ms |
12892 KB |
Output is correct |
14 |
Correct |
116 ms |
31460 KB |
Output is correct |
15 |
Correct |
3 ms |
12888 KB |
Output is correct |
16 |
Correct |
2 ms |
12892 KB |
Output is correct |
17 |
Correct |
3 ms |
12892 KB |
Output is correct |
18 |
Correct |
3 ms |
12892 KB |
Output is correct |
19 |
Correct |
2 ms |
12892 KB |
Output is correct |
20 |
Correct |
14 ms |
16340 KB |
Output is correct |
21 |
Correct |
3 ms |
12892 KB |
Output is correct |
22 |
Correct |
3 ms |
12892 KB |
Output is correct |
23 |
Correct |
3 ms |
12892 KB |
Output is correct |
24 |
Incorrect |
4 ms |
12892 KB |
Output isn't correct |
25 |
Halted |
0 ms |
0 KB |
- |