답안 #382247

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
382247 2021-03-26T20:06:18 Z MohamedAhmed04 Cheap flights (LMIO18_pigus_skrydziai) C++14
100 / 100
1502 ms 81644 KB
#include <bits/stdc++.h>

using namespace std ;

const int MAX = 3e5 + 10 ;

long long sum[MAX] ;
int n , m ;

vector< vector< pair<int , int> > >adj(MAX) ;

map< pair<int , int> , int>mp ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>m ;
	long long ans = 0 ; 
	for(int i = 0 ; i < m ; ++i)
	{
		int x , y , z ;
		cin>>x>>y>>z ;
		sum[x] += z , sum[y] += z ;
		mp[{x , y}] = mp[{y , x}] = z ;
		adj[x].emplace_back(z , y) ;
		adj[y].emplace_back(z , x) ;
	}
	for(int i = 1 ; i <= n ; ++i)
	{
		ans = max(ans , sum[i]) ;
		sort(adj[i].begin() , adj[i].end()) ;
		reverse(adj[i].begin() , adj[i].end()) ;
		if(adj[i].size() > 1)
		{
			long long x = adj[i][0].first , y = adj[i][1].first ;
			int a = adj[i][0].second , b = adj[i][1].second ;
			ans = max(ans , x + y + mp[{a , b}]) ;
		}
	}
	return cout<<ans<<"\n" , 0 ;
}		
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 7532 KB Output is correct
2 Correct 6 ms 7404 KB Output is correct
3 Correct 5 ms 7404 KB Output is correct
4 Correct 6 ms 7404 KB Output is correct
5 Correct 6 ms 7404 KB Output is correct
6 Correct 23 ms 10604 KB Output is correct
7 Correct 6 ms 7404 KB Output is correct
8 Correct 6 ms 7404 KB Output is correct
9 Correct 5 ms 7404 KB Output is correct
10 Correct 6 ms 7404 KB Output is correct
11 Correct 7 ms 7532 KB Output is correct
12 Correct 6 ms 7404 KB Output is correct
13 Correct 5 ms 7404 KB Output is correct
14 Correct 6 ms 7404 KB Output is correct
15 Correct 6 ms 7404 KB Output is correct
16 Correct 5 ms 7404 KB Output is correct
17 Correct 5 ms 7404 KB Output is correct
18 Correct 6 ms 7532 KB Output is correct
19 Correct 7 ms 7788 KB Output is correct
20 Correct 6 ms 7404 KB Output is correct
21 Correct 5 ms 7404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 7532 KB Output is correct
2 Correct 6 ms 7404 KB Output is correct
3 Correct 5 ms 7404 KB Output is correct
4 Correct 6 ms 7404 KB Output is correct
5 Correct 6 ms 7404 KB Output is correct
6 Correct 23 ms 10604 KB Output is correct
7 Correct 6 ms 7404 KB Output is correct
8 Correct 6 ms 7404 KB Output is correct
9 Correct 5 ms 7404 KB Output is correct
10 Correct 6 ms 7404 KB Output is correct
11 Correct 7 ms 7532 KB Output is correct
12 Correct 6 ms 7404 KB Output is correct
13 Correct 5 ms 7404 KB Output is correct
14 Correct 6 ms 7404 KB Output is correct
15 Correct 6 ms 7404 KB Output is correct
16 Correct 5 ms 7404 KB Output is correct
17 Correct 5 ms 7404 KB Output is correct
18 Correct 6 ms 7532 KB Output is correct
19 Correct 7 ms 7788 KB Output is correct
20 Correct 6 ms 7404 KB Output is correct
21 Correct 5 ms 7404 KB Output is correct
22 Correct 1502 ms 81644 KB Output is correct
23 Correct 633 ms 78968 KB Output is correct
24 Correct 31 ms 10880 KB Output is correct
25 Correct 13 ms 8428 KB Output is correct
26 Correct 12 ms 8464 KB Output is correct
27 Correct 9 ms 7916 KB Output is correct
28 Correct 560 ms 37228 KB Output is correct
29 Correct 153 ms 19820 KB Output is correct
30 Correct 291 ms 25708 KB Output is correct
31 Correct 7 ms 7532 KB Output is correct
32 Correct 7 ms 7532 KB Output is correct
33 Correct 663 ms 79752 KB Output is correct
34 Correct 586 ms 73892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 281 ms 38508 KB Output is correct
2 Correct 801 ms 76268 KB Output is correct
3 Correct 227 ms 30828 KB Output is correct
4 Correct 453 ms 51564 KB Output is correct
5 Correct 1215 ms 67172 KB Output is correct
6 Correct 124 ms 25708 KB Output is correct
7 Correct 266 ms 60656 KB Output is correct
8 Correct 306 ms 57324 KB Output is correct
9 Correct 9 ms 9836 KB Output is correct
10 Correct 128 ms 25708 KB Output is correct
11 Correct 315 ms 53852 KB Output is correct
12 Correct 290 ms 43500 KB Output is correct
13 Correct 6 ms 7404 KB Output is correct
14 Correct 188 ms 22892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 281 ms 38508 KB Output is correct
2 Correct 801 ms 76268 KB Output is correct
3 Correct 227 ms 30828 KB Output is correct
4 Correct 453 ms 51564 KB Output is correct
5 Correct 1215 ms 67172 KB Output is correct
6 Correct 124 ms 25708 KB Output is correct
7 Correct 266 ms 60656 KB Output is correct
8 Correct 306 ms 57324 KB Output is correct
9 Correct 9 ms 9836 KB Output is correct
10 Correct 128 ms 25708 KB Output is correct
11 Correct 315 ms 53852 KB Output is correct
12 Correct 290 ms 43500 KB Output is correct
13 Correct 6 ms 7404 KB Output is correct
14 Correct 188 ms 22892 KB Output is correct
15 Correct 6 ms 7532 KB Output is correct
16 Correct 6 ms 7404 KB Output is correct
17 Correct 5 ms 7404 KB Output is correct
18 Correct 6 ms 7404 KB Output is correct
19 Correct 6 ms 7404 KB Output is correct
20 Correct 23 ms 10604 KB Output is correct
21 Correct 6 ms 7404 KB Output is correct
22 Correct 6 ms 7404 KB Output is correct
23 Correct 5 ms 7404 KB Output is correct
24 Correct 6 ms 7404 KB Output is correct
25 Correct 7 ms 7532 KB Output is correct
26 Correct 6 ms 7404 KB Output is correct
27 Correct 5 ms 7404 KB Output is correct
28 Correct 6 ms 7404 KB Output is correct
29 Correct 6 ms 7404 KB Output is correct
30 Correct 5 ms 7404 KB Output is correct
31 Correct 5 ms 7404 KB Output is correct
32 Correct 6 ms 7532 KB Output is correct
33 Correct 7 ms 7788 KB Output is correct
34 Correct 6 ms 7404 KB Output is correct
35 Correct 5 ms 7404 KB Output is correct
36 Correct 1502 ms 81644 KB Output is correct
37 Correct 633 ms 78968 KB Output is correct
38 Correct 31 ms 10880 KB Output is correct
39 Correct 13 ms 8428 KB Output is correct
40 Correct 12 ms 8464 KB Output is correct
41 Correct 9 ms 7916 KB Output is correct
42 Correct 560 ms 37228 KB Output is correct
43 Correct 153 ms 19820 KB Output is correct
44 Correct 291 ms 25708 KB Output is correct
45 Correct 7 ms 7532 KB Output is correct
46 Correct 7 ms 7532 KB Output is correct
47 Correct 663 ms 79752 KB Output is correct
48 Correct 586 ms 73892 KB Output is correct
49 Correct 539 ms 40012 KB Output is correct
50 Correct 486 ms 37356 KB Output is correct
51 Correct 528 ms 42980 KB Output is correct
52 Correct 800 ms 50252 KB Output is correct
53 Correct 197 ms 25056 KB Output is correct
54 Correct 899 ms 54124 KB Output is correct
55 Correct 779 ms 76140 KB Output is correct
56 Correct 497 ms 53456 KB Output is correct
57 Correct 593 ms 53852 KB Output is correct
58 Correct 390 ms 31956 KB Output is correct
59 Correct 935 ms 56172 KB Output is correct
60 Correct 792 ms 52680 KB Output is correct
61 Correct 834 ms 50540 KB Output is correct