This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll maxN = 5e5+10;
ll n, m;
ll v[maxN];
vector<ll> adj[maxN];
map<pair<ll, ll>, ll> a;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(nullptr);
for(int i = 0; i < maxN; i++)v[i]=0;
cin>>n>>m;
for(int i = 0; i < m; i++){
ll aa, bb, cc;
cin>>aa>>bb>>cc;
v[aa]+=cc;
v[bb]+=cc;
adj[aa].push_back(bb);
adj[bb].push_back(aa);
a[{aa, bb}]=cc;
a[{bb, aa}]=cc;
}
ll res=0;
for(int i = 1; i <= n; i++){
res=max(res, v[i]);
for(ll x = 0; x < (ll)(adj[i].size())-1; x++){
ll vv=adj[i][x], vvv=adj[i][x+1];
if(a.count({i, x})){
res=max(res, a[{i, vv}]+a[{i, vvv}]+a[{vv, vvv}]);
}
}
}
cout<<res;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |