#include<bits/stdc++.h>
#define f first
#define int long long
#define s second
using namespace std;
const int N=3e5+5,mod=1e9+7;
int t,n,m;
map<int,int> f[N];
vector<pair<int,int> >V[N];
string s;
main(){
// t=1;
cin>>n>>m;
for(int i=1;i<=m;i++){
int u,v,w;
cin>>u>>v>>w;
V[u].push_back({w,v});
V[v].push_back({w,u});
f[u][v]=f[v][u]=w;
}
int ans = 0;
for(int u=1;u<=n;u++){
sort(V[u].begin(),V[u].end());
reverse(V[u].begin(),V[u].end());
int sum=0;
for(int j=0;j<V[u].size();j++){
sum += V[u][j].f;
}
if(V[u].size()>1) ans=max(ans,V[u][0].f+V[u][1].f+f[V[u][0].s][V[u][1].s]);
ans=max(ans,sum);
}
cout<<ans;
}
Compilation message
pigus_skrydziai.cpp:11:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
11 | main(){
| ^
pigus_skrydziai.cpp: In function 'int main()':
pigus_skrydziai.cpp:26:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | for(int j=0;j<V[u].size();j++){
| ~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
21328 KB |
Output is correct |
2 |
Correct |
14 ms |
21432 KB |
Output is correct |
3 |
Correct |
13 ms |
21328 KB |
Output is correct |
4 |
Correct |
14 ms |
21324 KB |
Output is correct |
5 |
Correct |
14 ms |
21416 KB |
Output is correct |
6 |
Correct |
38 ms |
24692 KB |
Output is correct |
7 |
Correct |
14 ms |
21460 KB |
Output is correct |
8 |
Correct |
14 ms |
21440 KB |
Output is correct |
9 |
Correct |
14 ms |
21452 KB |
Output is correct |
10 |
Correct |
14 ms |
21452 KB |
Output is correct |
11 |
Correct |
14 ms |
21452 KB |
Output is correct |
12 |
Correct |
14 ms |
21452 KB |
Output is correct |
13 |
Correct |
14 ms |
21388 KB |
Output is correct |
14 |
Correct |
15 ms |
21324 KB |
Output is correct |
15 |
Correct |
15 ms |
21324 KB |
Output is correct |
16 |
Correct |
14 ms |
21412 KB |
Output is correct |
17 |
Correct |
14 ms |
21368 KB |
Output is correct |
18 |
Correct |
16 ms |
21580 KB |
Output is correct |
19 |
Correct |
16 ms |
21684 KB |
Output is correct |
20 |
Correct |
14 ms |
21452 KB |
Output is correct |
21 |
Correct |
14 ms |
21412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
21328 KB |
Output is correct |
2 |
Correct |
14 ms |
21432 KB |
Output is correct |
3 |
Correct |
13 ms |
21328 KB |
Output is correct |
4 |
Correct |
14 ms |
21324 KB |
Output is correct |
5 |
Correct |
14 ms |
21416 KB |
Output is correct |
6 |
Correct |
38 ms |
24692 KB |
Output is correct |
7 |
Correct |
14 ms |
21460 KB |
Output is correct |
8 |
Correct |
14 ms |
21440 KB |
Output is correct |
9 |
Correct |
14 ms |
21452 KB |
Output is correct |
10 |
Correct |
14 ms |
21452 KB |
Output is correct |
11 |
Correct |
14 ms |
21452 KB |
Output is correct |
12 |
Correct |
14 ms |
21452 KB |
Output is correct |
13 |
Correct |
14 ms |
21388 KB |
Output is correct |
14 |
Correct |
15 ms |
21324 KB |
Output is correct |
15 |
Correct |
15 ms |
21324 KB |
Output is correct |
16 |
Correct |
14 ms |
21412 KB |
Output is correct |
17 |
Correct |
14 ms |
21368 KB |
Output is correct |
18 |
Correct |
16 ms |
21580 KB |
Output is correct |
19 |
Correct |
16 ms |
21684 KB |
Output is correct |
20 |
Correct |
14 ms |
21452 KB |
Output is correct |
21 |
Correct |
14 ms |
21412 KB |
Output is correct |
22 |
Correct |
1635 ms |
104912 KB |
Output is correct |
23 |
Correct |
819 ms |
100252 KB |
Output is correct |
24 |
Correct |
49 ms |
24876 KB |
Output is correct |
25 |
Correct |
22 ms |
22444 KB |
Output is correct |
26 |
Correct |
22 ms |
22536 KB |
Output is correct |
27 |
Correct |
18 ms |
21928 KB |
Output is correct |
28 |
Correct |
622 ms |
54728 KB |
Output is correct |
29 |
Correct |
175 ms |
34756 KB |
Output is correct |
30 |
Correct |
319 ms |
41064 KB |
Output is correct |
31 |
Correct |
15 ms |
21568 KB |
Output is correct |
32 |
Correct |
14 ms |
21472 KB |
Output is correct |
33 |
Correct |
749 ms |
103044 KB |
Output is correct |
34 |
Correct |
622 ms |
96512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
275 ms |
51896 KB |
Output is correct |
2 |
Correct |
706 ms |
97488 KB |
Output is correct |
3 |
Correct |
213 ms |
46660 KB |
Output is correct |
4 |
Correct |
419 ms |
70152 KB |
Output is correct |
5 |
Correct |
859 ms |
88980 KB |
Output is correct |
6 |
Correct |
185 ms |
42308 KB |
Output is correct |
7 |
Correct |
315 ms |
79884 KB |
Output is correct |
8 |
Correct |
367 ms |
77632 KB |
Output is correct |
9 |
Correct |
16 ms |
21628 KB |
Output is correct |
10 |
Correct |
162 ms |
42384 KB |
Output is correct |
11 |
Correct |
431 ms |
78392 KB |
Output is correct |
12 |
Correct |
314 ms |
63244 KB |
Output is correct |
13 |
Correct |
14 ms |
21324 KB |
Output is correct |
14 |
Correct |
202 ms |
39236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
275 ms |
51896 KB |
Output is correct |
2 |
Correct |
706 ms |
97488 KB |
Output is correct |
3 |
Correct |
213 ms |
46660 KB |
Output is correct |
4 |
Correct |
419 ms |
70152 KB |
Output is correct |
5 |
Correct |
859 ms |
88980 KB |
Output is correct |
6 |
Correct |
185 ms |
42308 KB |
Output is correct |
7 |
Correct |
315 ms |
79884 KB |
Output is correct |
8 |
Correct |
367 ms |
77632 KB |
Output is correct |
9 |
Correct |
16 ms |
21628 KB |
Output is correct |
10 |
Correct |
162 ms |
42384 KB |
Output is correct |
11 |
Correct |
431 ms |
78392 KB |
Output is correct |
12 |
Correct |
314 ms |
63244 KB |
Output is correct |
13 |
Correct |
14 ms |
21324 KB |
Output is correct |
14 |
Correct |
202 ms |
39236 KB |
Output is correct |
15 |
Correct |
14 ms |
21328 KB |
Output is correct |
16 |
Correct |
14 ms |
21432 KB |
Output is correct |
17 |
Correct |
13 ms |
21328 KB |
Output is correct |
18 |
Correct |
14 ms |
21324 KB |
Output is correct |
19 |
Correct |
14 ms |
21416 KB |
Output is correct |
20 |
Correct |
38 ms |
24692 KB |
Output is correct |
21 |
Correct |
14 ms |
21460 KB |
Output is correct |
22 |
Correct |
14 ms |
21440 KB |
Output is correct |
23 |
Correct |
14 ms |
21452 KB |
Output is correct |
24 |
Correct |
14 ms |
21452 KB |
Output is correct |
25 |
Correct |
14 ms |
21452 KB |
Output is correct |
26 |
Correct |
14 ms |
21452 KB |
Output is correct |
27 |
Correct |
14 ms |
21388 KB |
Output is correct |
28 |
Correct |
15 ms |
21324 KB |
Output is correct |
29 |
Correct |
15 ms |
21324 KB |
Output is correct |
30 |
Correct |
14 ms |
21412 KB |
Output is correct |
31 |
Correct |
14 ms |
21368 KB |
Output is correct |
32 |
Correct |
16 ms |
21580 KB |
Output is correct |
33 |
Correct |
16 ms |
21684 KB |
Output is correct |
34 |
Correct |
14 ms |
21452 KB |
Output is correct |
35 |
Correct |
14 ms |
21412 KB |
Output is correct |
36 |
Correct |
1635 ms |
104912 KB |
Output is correct |
37 |
Correct |
819 ms |
100252 KB |
Output is correct |
38 |
Correct |
49 ms |
24876 KB |
Output is correct |
39 |
Correct |
22 ms |
22444 KB |
Output is correct |
40 |
Correct |
22 ms |
22536 KB |
Output is correct |
41 |
Correct |
18 ms |
21928 KB |
Output is correct |
42 |
Correct |
622 ms |
54728 KB |
Output is correct |
43 |
Correct |
175 ms |
34756 KB |
Output is correct |
44 |
Correct |
319 ms |
41064 KB |
Output is correct |
45 |
Correct |
15 ms |
21568 KB |
Output is correct |
46 |
Correct |
14 ms |
21472 KB |
Output is correct |
47 |
Correct |
749 ms |
103044 KB |
Output is correct |
48 |
Correct |
622 ms |
96512 KB |
Output is correct |
49 |
Correct |
560 ms |
59864 KB |
Output is correct |
50 |
Correct |
555 ms |
58072 KB |
Output is correct |
51 |
Correct |
677 ms |
62412 KB |
Output is correct |
52 |
Correct |
860 ms |
72848 KB |
Output is correct |
53 |
Correct |
263 ms |
40328 KB |
Output is correct |
54 |
Correct |
902 ms |
78816 KB |
Output is correct |
55 |
Correct |
770 ms |
100228 KB |
Output is correct |
56 |
Correct |
515 ms |
73668 KB |
Output is correct |
57 |
Correct |
684 ms |
71848 KB |
Output is correct |
58 |
Correct |
385 ms |
49716 KB |
Output is correct |
59 |
Correct |
830 ms |
79996 KB |
Output is correct |
60 |
Correct |
833 ms |
74772 KB |
Output is correct |
61 |
Correct |
850 ms |
72644 KB |
Output is correct |