#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define loop(_) for (int __ = 0; __ < (_); ++__)
#define pb push_back
#define f first
#define s second
#define sz(_) ((int)_.size())
#define all(_) _.begin(), _.end()
#define lb lower_bound
#define ub upper_bound
using ll = long long;
using ld = long double;
const int N = 3e5 + 7;
const ll mod = 1e9 + 7;
int n, m;
ll a[N];
map<pii, ll> cost;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
#ifndef ONLINE_JUDGE
#endif
cin >> n >> m;
ll ans = 0;
bool case3 = 1;
for (int i = 0; i < m; ++i)
{
int u, v, w;
cin >> u >> v >> w;
a[u] += w;
a[v] += w;
ans = max({ans, a[u], a[v]});
cost[{u, v}] = cost[{v, u}] = w;
case3 &= w == 1;
}
for (int i = 1; i <= n; ++i)
{
for (int j = i + 1; j <= n; ++j)
{
for (int k = j + 1; k <= n; ++k)
{
if (cost[{i, j}] && cost[{i, k}] && cost[{j, k}])
{
ans = max(ans, cost[{i, j}] + cost[{j, k}] + cost[{i, k}]);
}
}
}
}
if(case3 && m >= n){
ans = max(ans , 3ll) ;
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
432 ms |
2796 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
35 ms |
1372 KB |
Output is correct |
12 |
Correct |
25 ms |
1004 KB |
Output is correct |
13 |
Correct |
36 ms |
1388 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
10 ms |
748 KB |
Output is correct |
19 |
Correct |
55 ms |
1740 KB |
Output is correct |
20 |
Correct |
31 ms |
1388 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
432 ms |
2796 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
35 ms |
1372 KB |
Output is correct |
12 |
Correct |
25 ms |
1004 KB |
Output is correct |
13 |
Correct |
36 ms |
1388 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
10 ms |
748 KB |
Output is correct |
19 |
Correct |
55 ms |
1740 KB |
Output is correct |
20 |
Correct |
31 ms |
1388 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Execution timed out |
3086 ms |
70100 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3076 ms |
40300 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3076 ms |
40300 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |