#include <bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(0);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
using namespace std;
unordered_map<ll,ll>adj[300010];
ll n,m;
int main(){
FLASH;
cin>>n>>m;
for(ll i=1;i<=m;i++)
{
ll x,y,z;
cin>>x>>y>>z;
adj[x][y]=z;
adj[y][x]=z;
}
ll maxx=0;
ll summ=0;
for(ll i=1;i<=n;i++)
{
summ=0;
for(auto j:adj[i])summ+=j.second;
maxx=max(maxx,summ);
}
for(ll i=1;i<=n;i++)
{
for(auto j:adj[i])
{
for(auto j1:adj[j.first])
{
ll y=j1.first;
if(y==i)continue;
auto yy=j1.first;
ll ch=adj[yy][i];
if(ch!=0)
{
maxx=max(maxx,j.second+j1.second+ch);
}
}
}
}
cout<<maxx<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
16768 KB |
Output is correct |
2 |
Correct |
12 ms |
16768 KB |
Output is correct |
3 |
Correct |
12 ms |
16768 KB |
Output is correct |
4 |
Correct |
12 ms |
16768 KB |
Output is correct |
5 |
Correct |
12 ms |
16768 KB |
Output is correct |
6 |
Correct |
148 ms |
18560 KB |
Output is correct |
7 |
Correct |
12 ms |
16768 KB |
Output is correct |
8 |
Correct |
12 ms |
16768 KB |
Output is correct |
9 |
Correct |
13 ms |
16768 KB |
Output is correct |
10 |
Correct |
12 ms |
16768 KB |
Output is correct |
11 |
Correct |
18 ms |
17280 KB |
Output is correct |
12 |
Correct |
17 ms |
17408 KB |
Output is correct |
13 |
Correct |
13 ms |
16768 KB |
Output is correct |
14 |
Correct |
12 ms |
16800 KB |
Output is correct |
15 |
Correct |
12 ms |
16768 KB |
Output is correct |
16 |
Correct |
12 ms |
16768 KB |
Output is correct |
17 |
Correct |
12 ms |
16768 KB |
Output is correct |
18 |
Correct |
21 ms |
17280 KB |
Output is correct |
19 |
Correct |
69 ms |
18296 KB |
Output is correct |
20 |
Correct |
13 ms |
16768 KB |
Output is correct |
21 |
Correct |
12 ms |
16768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
16768 KB |
Output is correct |
2 |
Correct |
12 ms |
16768 KB |
Output is correct |
3 |
Correct |
12 ms |
16768 KB |
Output is correct |
4 |
Correct |
12 ms |
16768 KB |
Output is correct |
5 |
Correct |
12 ms |
16768 KB |
Output is correct |
6 |
Correct |
148 ms |
18560 KB |
Output is correct |
7 |
Correct |
12 ms |
16768 KB |
Output is correct |
8 |
Correct |
12 ms |
16768 KB |
Output is correct |
9 |
Correct |
13 ms |
16768 KB |
Output is correct |
10 |
Correct |
12 ms |
16768 KB |
Output is correct |
11 |
Correct |
18 ms |
17280 KB |
Output is correct |
12 |
Correct |
17 ms |
17408 KB |
Output is correct |
13 |
Correct |
13 ms |
16768 KB |
Output is correct |
14 |
Correct |
12 ms |
16800 KB |
Output is correct |
15 |
Correct |
12 ms |
16768 KB |
Output is correct |
16 |
Correct |
12 ms |
16768 KB |
Output is correct |
17 |
Correct |
12 ms |
16768 KB |
Output is correct |
18 |
Correct |
21 ms |
17280 KB |
Output is correct |
19 |
Correct |
69 ms |
18296 KB |
Output is correct |
20 |
Correct |
13 ms |
16768 KB |
Output is correct |
21 |
Correct |
12 ms |
16768 KB |
Output is correct |
22 |
Execution timed out |
3082 ms |
96816 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
165 ms |
37752 KB |
Output is correct |
2 |
Correct |
481 ms |
72952 KB |
Output is correct |
3 |
Correct |
157 ms |
35324 KB |
Output is correct |
4 |
Correct |
356 ms |
69464 KB |
Output is correct |
5 |
Execution timed out |
3090 ms |
192928 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
165 ms |
37752 KB |
Output is correct |
2 |
Correct |
481 ms |
72952 KB |
Output is correct |
3 |
Correct |
157 ms |
35324 KB |
Output is correct |
4 |
Correct |
356 ms |
69464 KB |
Output is correct |
5 |
Execution timed out |
3090 ms |
192928 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |