#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;
int N,M;
unordered_map<int,ll> mp[mxn];
vector<tlll> edges;
ll sum[mxn];
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
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));
}
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(mp[b].find(j.fs) != mp[b].end()){
ans = max(ans,mp[b][j.fs]+j.sc+ts);
}
}
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
16984 KB |
Output is correct |
2 |
Correct |
5 ms |
16988 KB |
Output is correct |
3 |
Correct |
6 ms |
16844 KB |
Output is correct |
4 |
Correct |
6 ms |
17240 KB |
Output is correct |
5 |
Correct |
6 ms |
16988 KB |
Output is correct |
6 |
Correct |
55 ms |
19096 KB |
Output is correct |
7 |
Correct |
6 ms |
16988 KB |
Output is correct |
8 |
Correct |
5 ms |
16988 KB |
Output is correct |
9 |
Correct |
5 ms |
16988 KB |
Output is correct |
10 |
Correct |
5 ms |
16988 KB |
Output is correct |
11 |
Correct |
6 ms |
16984 KB |
Output is correct |
12 |
Correct |
5 ms |
16988 KB |
Output is correct |
13 |
Correct |
5 ms |
16988 KB |
Output is correct |
14 |
Correct |
7 ms |
17396 KB |
Output is correct |
15 |
Correct |
5 ms |
16988 KB |
Output is correct |
16 |
Correct |
5 ms |
16988 KB |
Output is correct |
17 |
Correct |
6 ms |
16988 KB |
Output is correct |
18 |
Correct |
7 ms |
17084 KB |
Output is correct |
19 |
Correct |
7 ms |
17240 KB |
Output is correct |
20 |
Correct |
6 ms |
16988 KB |
Output is correct |
21 |
Correct |
6 ms |
16988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
16984 KB |
Output is correct |
2 |
Correct |
5 ms |
16988 KB |
Output is correct |
3 |
Correct |
6 ms |
16844 KB |
Output is correct |
4 |
Correct |
6 ms |
17240 KB |
Output is correct |
5 |
Correct |
6 ms |
16988 KB |
Output is correct |
6 |
Correct |
55 ms |
19096 KB |
Output is correct |
7 |
Correct |
6 ms |
16988 KB |
Output is correct |
8 |
Correct |
5 ms |
16988 KB |
Output is correct |
9 |
Correct |
5 ms |
16988 KB |
Output is correct |
10 |
Correct |
5 ms |
16988 KB |
Output is correct |
11 |
Correct |
6 ms |
16984 KB |
Output is correct |
12 |
Correct |
5 ms |
16988 KB |
Output is correct |
13 |
Correct |
5 ms |
16988 KB |
Output is correct |
14 |
Correct |
7 ms |
17396 KB |
Output is correct |
15 |
Correct |
5 ms |
16988 KB |
Output is correct |
16 |
Correct |
5 ms |
16988 KB |
Output is correct |
17 |
Correct |
6 ms |
16988 KB |
Output is correct |
18 |
Correct |
7 ms |
17084 KB |
Output is correct |
19 |
Correct |
7 ms |
17240 KB |
Output is correct |
20 |
Correct |
6 ms |
16988 KB |
Output is correct |
21 |
Correct |
6 ms |
16988 KB |
Output is correct |
22 |
Execution timed out |
3038 ms |
70360 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
169 ms |
65932 KB |
Output is correct |
2 |
Correct |
400 ms |
81908 KB |
Output is correct |
3 |
Correct |
110 ms |
38868 KB |
Output is correct |
4 |
Correct |
292 ms |
58264 KB |
Output is correct |
5 |
Correct |
552 ms |
68856 KB |
Output is correct |
6 |
Correct |
701 ms |
29692 KB |
Output is correct |
7 |
Correct |
110 ms |
69364 KB |
Output is correct |
8 |
Correct |
134 ms |
78060 KB |
Output is correct |
9 |
Correct |
7 ms |
19548 KB |
Output is correct |
10 |
Correct |
706 ms |
29728 KB |
Output is correct |
11 |
Correct |
133 ms |
68340 KB |
Output is correct |
12 |
Correct |
1520 ms |
42664 KB |
Output is correct |
13 |
Correct |
5 ms |
16984 KB |
Output is correct |
14 |
Correct |
268 ms |
27648 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
169 ms |
65932 KB |
Output is correct |
2 |
Correct |
400 ms |
81908 KB |
Output is correct |
3 |
Correct |
110 ms |
38868 KB |
Output is correct |
4 |
Correct |
292 ms |
58264 KB |
Output is correct |
5 |
Correct |
552 ms |
68856 KB |
Output is correct |
6 |
Correct |
701 ms |
29692 KB |
Output is correct |
7 |
Correct |
110 ms |
69364 KB |
Output is correct |
8 |
Correct |
134 ms |
78060 KB |
Output is correct |
9 |
Correct |
7 ms |
19548 KB |
Output is correct |
10 |
Correct |
706 ms |
29728 KB |
Output is correct |
11 |
Correct |
133 ms |
68340 KB |
Output is correct |
12 |
Correct |
1520 ms |
42664 KB |
Output is correct |
13 |
Correct |
5 ms |
16984 KB |
Output is correct |
14 |
Correct |
268 ms |
27648 KB |
Output is correct |
15 |
Correct |
5 ms |
16984 KB |
Output is correct |
16 |
Correct |
5 ms |
16988 KB |
Output is correct |
17 |
Correct |
6 ms |
16844 KB |
Output is correct |
18 |
Correct |
6 ms |
17240 KB |
Output is correct |
19 |
Correct |
6 ms |
16988 KB |
Output is correct |
20 |
Correct |
55 ms |
19096 KB |
Output is correct |
21 |
Correct |
6 ms |
16988 KB |
Output is correct |
22 |
Correct |
5 ms |
16988 KB |
Output is correct |
23 |
Correct |
5 ms |
16988 KB |
Output is correct |
24 |
Correct |
5 ms |
16988 KB |
Output is correct |
25 |
Correct |
6 ms |
16984 KB |
Output is correct |
26 |
Correct |
5 ms |
16988 KB |
Output is correct |
27 |
Correct |
5 ms |
16988 KB |
Output is correct |
28 |
Correct |
7 ms |
17396 KB |
Output is correct |
29 |
Correct |
5 ms |
16988 KB |
Output is correct |
30 |
Correct |
5 ms |
16988 KB |
Output is correct |
31 |
Correct |
6 ms |
16988 KB |
Output is correct |
32 |
Correct |
7 ms |
17084 KB |
Output is correct |
33 |
Correct |
7 ms |
17240 KB |
Output is correct |
34 |
Correct |
6 ms |
16988 KB |
Output is correct |
35 |
Correct |
6 ms |
16988 KB |
Output is correct |
36 |
Execution timed out |
3038 ms |
70360 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |