#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,popcnt")
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
const int mxn = 3e5+10;
const int lim = 2.6*CLOCKS_PER_SEC;
int N,M;
cc_hash_table<int,ll> mp[mxn];
vector<tlll> edges;
ll sum[mxn];
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int st = clock();
cin>>N>>M;
for(int i = 0;i<M;i++){
int a,b,c;
cin>>a>>b>>c;
mp[a][b] = c;
mp[b][a] = c;
sum[a] += c;
sum[b] += c;
edges.push_back(make_tuple(a,b,c));
}
srand(time(NULL));
random_shuffle(edges.begin(),edges.end());
ll ans = *max_element(sum,sum+N+1);
for(auto &i:edges){
int a = get<0>(i),b = get<1>(i),ts = get<2>(i);
if(mp[a].size()>mp[b].size())swap(a,b);
for(auto &j:mp[a]){
if(clock()-st>=lim)break;
if(mp[b].find(j.fs) != mp[b].end()){
ans = max(ans,mp[b][j.fs]+j.sc+ts);
}
}
if(clock()-st>=lim)break;
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
54352 KB |
Output is correct |
2 |
Correct |
40 ms |
54444 KB |
Output is correct |
3 |
Correct |
41 ms |
54540 KB |
Output is correct |
4 |
Correct |
38 ms |
54428 KB |
Output is correct |
5 |
Correct |
36 ms |
54360 KB |
Output is correct |
6 |
Correct |
1355 ms |
56996 KB |
Output is correct |
7 |
Correct |
42 ms |
54364 KB |
Output is correct |
8 |
Correct |
39 ms |
54560 KB |
Output is correct |
9 |
Correct |
50 ms |
54600 KB |
Output is correct |
10 |
Correct |
39 ms |
54412 KB |
Output is correct |
11 |
Correct |
37 ms |
54612 KB |
Output is correct |
12 |
Correct |
38 ms |
54620 KB |
Output is correct |
13 |
Correct |
37 ms |
54356 KB |
Output is correct |
14 |
Correct |
36 ms |
54408 KB |
Output is correct |
15 |
Correct |
34 ms |
54356 KB |
Output is correct |
16 |
Correct |
35 ms |
54360 KB |
Output is correct |
17 |
Correct |
55 ms |
54352 KB |
Output is correct |
18 |
Correct |
50 ms |
54644 KB |
Output is correct |
19 |
Correct |
52 ms |
54840 KB |
Output is correct |
20 |
Correct |
35 ms |
54436 KB |
Output is correct |
21 |
Correct |
36 ms |
54364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
54352 KB |
Output is correct |
2 |
Correct |
40 ms |
54444 KB |
Output is correct |
3 |
Correct |
41 ms |
54540 KB |
Output is correct |
4 |
Correct |
38 ms |
54428 KB |
Output is correct |
5 |
Correct |
36 ms |
54360 KB |
Output is correct |
6 |
Correct |
1355 ms |
56996 KB |
Output is correct |
7 |
Correct |
42 ms |
54364 KB |
Output is correct |
8 |
Correct |
39 ms |
54560 KB |
Output is correct |
9 |
Correct |
50 ms |
54600 KB |
Output is correct |
10 |
Correct |
39 ms |
54412 KB |
Output is correct |
11 |
Correct |
37 ms |
54612 KB |
Output is correct |
12 |
Correct |
38 ms |
54620 KB |
Output is correct |
13 |
Correct |
37 ms |
54356 KB |
Output is correct |
14 |
Correct |
36 ms |
54408 KB |
Output is correct |
15 |
Correct |
34 ms |
54356 KB |
Output is correct |
16 |
Correct |
35 ms |
54360 KB |
Output is correct |
17 |
Correct |
55 ms |
54352 KB |
Output is correct |
18 |
Correct |
50 ms |
54644 KB |
Output is correct |
19 |
Correct |
52 ms |
54840 KB |
Output is correct |
20 |
Correct |
35 ms |
54436 KB |
Output is correct |
21 |
Correct |
36 ms |
54364 KB |
Output is correct |
22 |
Correct |
2852 ms |
117780 KB |
Output is correct |
23 |
Correct |
2672 ms |
113488 KB |
Output is correct |
24 |
Correct |
314 ms |
57100 KB |
Output is correct |
25 |
Correct |
62 ms |
55128 KB |
Output is correct |
26 |
Correct |
61 ms |
55132 KB |
Output is correct |
27 |
Correct |
45 ms |
54868 KB |
Output is correct |
28 |
Correct |
2679 ms |
80888 KB |
Output is correct |
29 |
Correct |
2649 ms |
64832 KB |
Output is correct |
30 |
Correct |
2657 ms |
69124 KB |
Output is correct |
31 |
Correct |
37 ms |
54616 KB |
Output is correct |
32 |
Correct |
35 ms |
54524 KB |
Output is correct |
33 |
Correct |
2801 ms |
119024 KB |
Output is correct |
34 |
Incorrect |
2779 ms |
115948 KB |
Output isn't correct |
35 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
358 ms |
72956 KB |
Output is correct |
2 |
Correct |
909 ms |
85996 KB |
Output is correct |
3 |
Correct |
269 ms |
65976 KB |
Output is correct |
4 |
Correct |
517 ms |
74212 KB |
Output is correct |
5 |
Correct |
1327 ms |
89880 KB |
Output is correct |
6 |
Correct |
2646 ms |
69120 KB |
Output is correct |
7 |
Correct |
568 ms |
78844 KB |
Output is correct |
8 |
Correct |
659 ms |
86772 KB |
Output is correct |
9 |
Correct |
36 ms |
56660 KB |
Output is correct |
10 |
Correct |
2653 ms |
69160 KB |
Output is correct |
11 |
Correct |
669 ms |
93272 KB |
Output is correct |
12 |
Correct |
2655 ms |
83956 KB |
Output is correct |
13 |
Correct |
34 ms |
54360 KB |
Output is correct |
14 |
Correct |
2653 ms |
67076 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
358 ms |
72956 KB |
Output is correct |
2 |
Correct |
909 ms |
85996 KB |
Output is correct |
3 |
Correct |
269 ms |
65976 KB |
Output is correct |
4 |
Correct |
517 ms |
74212 KB |
Output is correct |
5 |
Correct |
1327 ms |
89880 KB |
Output is correct |
6 |
Correct |
2646 ms |
69120 KB |
Output is correct |
7 |
Correct |
568 ms |
78844 KB |
Output is correct |
8 |
Correct |
659 ms |
86772 KB |
Output is correct |
9 |
Correct |
36 ms |
56660 KB |
Output is correct |
10 |
Correct |
2653 ms |
69160 KB |
Output is correct |
11 |
Correct |
669 ms |
93272 KB |
Output is correct |
12 |
Correct |
2655 ms |
83956 KB |
Output is correct |
13 |
Correct |
34 ms |
54360 KB |
Output is correct |
14 |
Correct |
2653 ms |
67076 KB |
Output is correct |
15 |
Correct |
37 ms |
54352 KB |
Output is correct |
16 |
Correct |
40 ms |
54444 KB |
Output is correct |
17 |
Correct |
41 ms |
54540 KB |
Output is correct |
18 |
Correct |
38 ms |
54428 KB |
Output is correct |
19 |
Correct |
36 ms |
54360 KB |
Output is correct |
20 |
Correct |
1355 ms |
56996 KB |
Output is correct |
21 |
Correct |
42 ms |
54364 KB |
Output is correct |
22 |
Correct |
39 ms |
54560 KB |
Output is correct |
23 |
Correct |
50 ms |
54600 KB |
Output is correct |
24 |
Correct |
39 ms |
54412 KB |
Output is correct |
25 |
Correct |
37 ms |
54612 KB |
Output is correct |
26 |
Correct |
38 ms |
54620 KB |
Output is correct |
27 |
Correct |
37 ms |
54356 KB |
Output is correct |
28 |
Correct |
36 ms |
54408 KB |
Output is correct |
29 |
Correct |
34 ms |
54356 KB |
Output is correct |
30 |
Correct |
35 ms |
54360 KB |
Output is correct |
31 |
Correct |
55 ms |
54352 KB |
Output is correct |
32 |
Correct |
50 ms |
54644 KB |
Output is correct |
33 |
Correct |
52 ms |
54840 KB |
Output is correct |
34 |
Correct |
35 ms |
54436 KB |
Output is correct |
35 |
Correct |
36 ms |
54364 KB |
Output is correct |
36 |
Correct |
2852 ms |
117780 KB |
Output is correct |
37 |
Correct |
2672 ms |
113488 KB |
Output is correct |
38 |
Correct |
314 ms |
57100 KB |
Output is correct |
39 |
Correct |
62 ms |
55128 KB |
Output is correct |
40 |
Correct |
61 ms |
55132 KB |
Output is correct |
41 |
Correct |
45 ms |
54868 KB |
Output is correct |
42 |
Correct |
2679 ms |
80888 KB |
Output is correct |
43 |
Correct |
2649 ms |
64832 KB |
Output is correct |
44 |
Correct |
2657 ms |
69124 KB |
Output is correct |
45 |
Correct |
37 ms |
54616 KB |
Output is correct |
46 |
Correct |
35 ms |
54524 KB |
Output is correct |
47 |
Correct |
2801 ms |
119024 KB |
Output is correct |
48 |
Incorrect |
2779 ms |
115948 KB |
Output isn't correct |
49 |
Halted |
0 ms |
0 KB |
- |