#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)
#define pb(a) push_back(a)
#define bit(x,b) (x&(1LL<<b))
typedef long long int lli;
typedef pair <lli,lli> ii;
typedef pair <ii,lli> iii;
typedef vector <lli> vi;
map<ii,lli> ma;
vector<ii> al[300001];
int main()
{
lli n,m;
cin>>n>>m;
for(lli i=0;i<m;++i)
{
lli f,s,w;
cin>>f>>s>>w;
al[f].pb(mp(w,s));
al[s].pb(mp(w,f));
ma[mp(f,s)]=w;
ma[mp(s,f)]=w;
}
lli ans=0;
for(lli i=1;i<=n;++i)
{
sort(all(al[i]),greater<ii>());
lli s=0;
for(lli j=0;j<al[i].size();++j)
s+=al[i][j].F;
if(al[i].size()>1&&ma.find(mp(al[i][0].S,al[i][1].S))!=ma.end())
s=max(s,al[i][0].F+al[i][1].F+ma[mp(al[i][0].S,al[i][1].S)]);
ans=max(ans,s);
}
cout<<ans<<endl;
return(0);
}
Compilation message
pigus_skrydziai.cpp: In function 'int main()':
pigus_skrydziai.cpp:37:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(lli j=0;j<al[i].size();++j)
~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7424 KB |
Output is correct |
2 |
Correct |
4 ms |
7296 KB |
Output is correct |
3 |
Correct |
5 ms |
7296 KB |
Output is correct |
4 |
Correct |
5 ms |
7296 KB |
Output is correct |
5 |
Correct |
5 ms |
7296 KB |
Output is correct |
6 |
Correct |
35 ms |
10880 KB |
Output is correct |
7 |
Correct |
5 ms |
7312 KB |
Output is correct |
8 |
Correct |
5 ms |
7296 KB |
Output is correct |
9 |
Correct |
5 ms |
7424 KB |
Output is correct |
10 |
Correct |
5 ms |
7424 KB |
Output is correct |
11 |
Correct |
6 ms |
7424 KB |
Output is correct |
12 |
Correct |
6 ms |
7424 KB |
Output is correct |
13 |
Correct |
5 ms |
7424 KB |
Output is correct |
14 |
Correct |
5 ms |
7424 KB |
Output is correct |
15 |
Correct |
4 ms |
7296 KB |
Output is correct |
16 |
Correct |
5 ms |
7424 KB |
Output is correct |
17 |
Correct |
5 ms |
7424 KB |
Output is correct |
18 |
Correct |
6 ms |
7552 KB |
Output is correct |
19 |
Correct |
9 ms |
7680 KB |
Output is correct |
20 |
Correct |
5 ms |
7424 KB |
Output is correct |
21 |
Correct |
5 ms |
7296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7424 KB |
Output is correct |
2 |
Correct |
4 ms |
7296 KB |
Output is correct |
3 |
Correct |
5 ms |
7296 KB |
Output is correct |
4 |
Correct |
5 ms |
7296 KB |
Output is correct |
5 |
Correct |
5 ms |
7296 KB |
Output is correct |
6 |
Correct |
35 ms |
10880 KB |
Output is correct |
7 |
Correct |
5 ms |
7312 KB |
Output is correct |
8 |
Correct |
5 ms |
7296 KB |
Output is correct |
9 |
Correct |
5 ms |
7424 KB |
Output is correct |
10 |
Correct |
5 ms |
7424 KB |
Output is correct |
11 |
Correct |
6 ms |
7424 KB |
Output is correct |
12 |
Correct |
6 ms |
7424 KB |
Output is correct |
13 |
Correct |
5 ms |
7424 KB |
Output is correct |
14 |
Correct |
5 ms |
7424 KB |
Output is correct |
15 |
Correct |
4 ms |
7296 KB |
Output is correct |
16 |
Correct |
5 ms |
7424 KB |
Output is correct |
17 |
Correct |
5 ms |
7424 KB |
Output is correct |
18 |
Correct |
6 ms |
7552 KB |
Output is correct |
19 |
Correct |
9 ms |
7680 KB |
Output is correct |
20 |
Correct |
5 ms |
7424 KB |
Output is correct |
21 |
Correct |
5 ms |
7296 KB |
Output is correct |
22 |
Correct |
2009 ms |
99192 KB |
Output is correct |
23 |
Correct |
1022 ms |
94844 KB |
Output is correct |
24 |
Correct |
46 ms |
11128 KB |
Output is correct |
25 |
Correct |
16 ms |
8448 KB |
Output is correct |
26 |
Correct |
16 ms |
8448 KB |
Output is correct |
27 |
Correct |
10 ms |
7936 KB |
Output is correct |
28 |
Correct |
654 ms |
43980 KB |
Output is correct |
29 |
Correct |
205 ms |
21752 KB |
Output is correct |
30 |
Correct |
380 ms |
29304 KB |
Output is correct |
31 |
Correct |
7 ms |
7552 KB |
Output is correct |
32 |
Correct |
5 ms |
7424 KB |
Output is correct |
33 |
Correct |
1037 ms |
97272 KB |
Output is correct |
34 |
Correct |
843 ms |
88076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
415 ms |
37852 KB |
Output is correct |
2 |
Correct |
996 ms |
64760 KB |
Output is correct |
3 |
Correct |
280 ms |
26488 KB |
Output is correct |
4 |
Correct |
593 ms |
44796 KB |
Output is correct |
5 |
Correct |
1369 ms |
65272 KB |
Output is correct |
6 |
Correct |
187 ms |
28280 KB |
Output is correct |
7 |
Correct |
469 ms |
55544 KB |
Output is correct |
8 |
Correct |
568 ms |
63480 KB |
Output is correct |
9 |
Correct |
7 ms |
7552 KB |
Output is correct |
10 |
Correct |
188 ms |
28280 KB |
Output is correct |
11 |
Correct |
516 ms |
64480 KB |
Output is correct |
12 |
Correct |
414 ms |
49144 KB |
Output is correct |
13 |
Correct |
5 ms |
7296 KB |
Output is correct |
14 |
Correct |
243 ms |
25208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
415 ms |
37852 KB |
Output is correct |
2 |
Correct |
996 ms |
64760 KB |
Output is correct |
3 |
Correct |
280 ms |
26488 KB |
Output is correct |
4 |
Correct |
593 ms |
44796 KB |
Output is correct |
5 |
Correct |
1369 ms |
65272 KB |
Output is correct |
6 |
Correct |
187 ms |
28280 KB |
Output is correct |
7 |
Correct |
469 ms |
55544 KB |
Output is correct |
8 |
Correct |
568 ms |
63480 KB |
Output is correct |
9 |
Correct |
7 ms |
7552 KB |
Output is correct |
10 |
Correct |
188 ms |
28280 KB |
Output is correct |
11 |
Correct |
516 ms |
64480 KB |
Output is correct |
12 |
Correct |
414 ms |
49144 KB |
Output is correct |
13 |
Correct |
5 ms |
7296 KB |
Output is correct |
14 |
Correct |
243 ms |
25208 KB |
Output is correct |
15 |
Correct |
681 ms |
45904 KB |
Output is correct |
16 |
Correct |
701 ms |
43988 KB |
Output is correct |
17 |
Correct |
776 ms |
48484 KB |
Output is correct |
18 |
Correct |
1064 ms |
58912 KB |
Output is correct |
19 |
Correct |
302 ms |
26468 KB |
Output is correct |
20 |
Correct |
1036 ms |
64632 KB |
Output is correct |
21 |
Correct |
1073 ms |
66100 KB |
Output is correct |
22 |
Correct |
686 ms |
47144 KB |
Output is correct |
23 |
Correct |
793 ms |
54620 KB |
Output is correct |
24 |
Correct |
431 ms |
35644 KB |
Output is correct |
25 |
Correct |
1185 ms |
63488 KB |
Output is correct |
26 |
Correct |
982 ms |
61048 KB |
Output is correct |
27 |
Correct |
991 ms |
59128 KB |
Output is correct |
28 |
Correct |
5 ms |
7424 KB |
Output is correct |
29 |
Correct |
4 ms |
7296 KB |
Output is correct |
30 |
Correct |
5 ms |
7296 KB |
Output is correct |
31 |
Correct |
5 ms |
7296 KB |
Output is correct |
32 |
Correct |
5 ms |
7296 KB |
Output is correct |
33 |
Correct |
35 ms |
10880 KB |
Output is correct |
34 |
Correct |
5 ms |
7312 KB |
Output is correct |
35 |
Correct |
5 ms |
7296 KB |
Output is correct |
36 |
Correct |
5 ms |
7424 KB |
Output is correct |
37 |
Correct |
5 ms |
7424 KB |
Output is correct |
38 |
Correct |
6 ms |
7424 KB |
Output is correct |
39 |
Correct |
6 ms |
7424 KB |
Output is correct |
40 |
Correct |
5 ms |
7424 KB |
Output is correct |
41 |
Correct |
5 ms |
7424 KB |
Output is correct |
42 |
Correct |
4 ms |
7296 KB |
Output is correct |
43 |
Correct |
5 ms |
7424 KB |
Output is correct |
44 |
Correct |
5 ms |
7424 KB |
Output is correct |
45 |
Correct |
6 ms |
7552 KB |
Output is correct |
46 |
Correct |
9 ms |
7680 KB |
Output is correct |
47 |
Correct |
5 ms |
7424 KB |
Output is correct |
48 |
Correct |
5 ms |
7296 KB |
Output is correct |
49 |
Correct |
2009 ms |
99192 KB |
Output is correct |
50 |
Correct |
1022 ms |
94844 KB |
Output is correct |
51 |
Correct |
46 ms |
11128 KB |
Output is correct |
52 |
Correct |
16 ms |
8448 KB |
Output is correct |
53 |
Correct |
16 ms |
8448 KB |
Output is correct |
54 |
Correct |
10 ms |
7936 KB |
Output is correct |
55 |
Correct |
654 ms |
43980 KB |
Output is correct |
56 |
Correct |
205 ms |
21752 KB |
Output is correct |
57 |
Correct |
380 ms |
29304 KB |
Output is correct |
58 |
Correct |
7 ms |
7552 KB |
Output is correct |
59 |
Correct |
5 ms |
7424 KB |
Output is correct |
60 |
Correct |
1037 ms |
97272 KB |
Output is correct |
61 |
Correct |
843 ms |
88076 KB |
Output is correct |