답안 #906454

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
906454 2024-01-14T10:11:08 Z pcc Cheap flights (LMIO18_pigus_skrydziai) C++14
53 / 100
2903 ms 80888 KB
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,popcnt")

#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>


const int mxn = 3e5+10;
const int lim = 2.6*CLOCKS_PER_SEC;
int N,M;
unordered_map<int,ll> mp[mxn];
vector<tlll> edges;
ll sum[mxn];

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int st = clock();
	cin>>N>>M;
	for(int i = 0;i<M;i++){
		int a,b,c;
		cin>>a>>b>>c;
		mp[a][b] = c;
		mp[b][a] = c;
		sum[a] += c;
		sum[b] += c;
		edges.push_back(make_tuple(a,b,c));
	}
	//srand(7123);
	random_shuffle(edges.begin(),edges.end());
	ll ans = *max_element(sum,sum+N+1);
	for(auto &i:edges){
		int a = get<0>(i),b = get<1>(i),ts = get<2>(i);
		if(mp[a].size()>mp[b].size())swap(a,b);
		for(auto &j:mp[a]){
			if(clock()-st>=lim)break;
			if(mp[b].find(j.fs) != mp[b].end()){
				ans = max(ans,mp[b][j.fs]+j.sc+ts);
			}
		}
		if(clock()-st>=lim)break;
	}
	cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 16988 KB Output is correct
2 Correct 5 ms 16984 KB Output is correct
3 Correct 5 ms 16816 KB Output is correct
4 Correct 5 ms 16988 KB Output is correct
5 Correct 5 ms 16988 KB Output is correct
6 Correct 1340 ms 19080 KB Output is correct
7 Correct 5 ms 16988 KB Output is correct
8 Correct 5 ms 16988 KB Output is correct
9 Correct 6 ms 16892 KB Output is correct
10 Correct 5 ms 16988 KB Output is correct
11 Correct 8 ms 16988 KB Output is correct
12 Correct 6 ms 16988 KB Output is correct
13 Correct 5 ms 16828 KB Output is correct
14 Correct 5 ms 16988 KB Output is correct
15 Correct 5 ms 16988 KB Output is correct
16 Correct 6 ms 16988 KB Output is correct
17 Correct 6 ms 16988 KB Output is correct
18 Correct 17 ms 16984 KB Output is correct
19 Correct 21 ms 17244 KB Output is correct
20 Correct 6 ms 16836 KB Output is correct
21 Correct 6 ms 16988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 16988 KB Output is correct
2 Correct 5 ms 16984 KB Output is correct
3 Correct 5 ms 16816 KB Output is correct
4 Correct 5 ms 16988 KB Output is correct
5 Correct 5 ms 16988 KB Output is correct
6 Correct 1340 ms 19080 KB Output is correct
7 Correct 5 ms 16988 KB Output is correct
8 Correct 5 ms 16988 KB Output is correct
9 Correct 6 ms 16892 KB Output is correct
10 Correct 5 ms 16988 KB Output is correct
11 Correct 8 ms 16988 KB Output is correct
12 Correct 6 ms 16988 KB Output is correct
13 Correct 5 ms 16828 KB Output is correct
14 Correct 5 ms 16988 KB Output is correct
15 Correct 5 ms 16988 KB Output is correct
16 Correct 6 ms 16988 KB Output is correct
17 Correct 6 ms 16988 KB Output is correct
18 Correct 17 ms 16984 KB Output is correct
19 Correct 21 ms 17244 KB Output is correct
20 Correct 6 ms 16836 KB Output is correct
21 Correct 6 ms 16988 KB Output is correct
22 Correct 2903 ms 70200 KB Output is correct
23 Correct 2680 ms 68588 KB Output is correct
24 Correct 287 ms 19216 KB Output is correct
25 Correct 34 ms 17496 KB Output is correct
26 Correct 33 ms 17500 KB Output is correct
27 Correct 11 ms 17244 KB Output is correct
28 Correct 2659 ms 39412 KB Output is correct
29 Correct 2619 ms 25860 KB Output is correct
30 Correct 2630 ms 29700 KB Output is correct
31 Correct 6 ms 16984 KB Output is correct
32 Correct 6 ms 16988 KB Output is correct
33 Correct 2656 ms 68092 KB Output is correct
34 Correct 2652 ms 64076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 306 ms 66556 KB Output is correct
2 Correct 833 ms 80888 KB Output is correct
3 Correct 225 ms 38652 KB Output is correct
4 Correct 516 ms 58548 KB Output is correct
5 Correct 1165 ms 69592 KB Output is correct
6 Correct 2628 ms 29952 KB Output is correct
7 Correct 469 ms 69360 KB Output is correct
8 Correct 591 ms 78080 KB Output is correct
9 Correct 8 ms 19548 KB Output is correct
10 Correct 2633 ms 29692 KB Output is correct
11 Correct 557 ms 68592 KB Output is correct
12 Correct 2641 ms 42736 KB Output is correct
13 Correct 6 ms 16984 KB Output is correct
14 Correct 2621 ms 28148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 306 ms 66556 KB Output is correct
2 Correct 833 ms 80888 KB Output is correct
3 Correct 225 ms 38652 KB Output is correct
4 Correct 516 ms 58548 KB Output is correct
5 Correct 1165 ms 69592 KB Output is correct
6 Correct 2628 ms 29952 KB Output is correct
7 Correct 469 ms 69360 KB Output is correct
8 Correct 591 ms 78080 KB Output is correct
9 Correct 8 ms 19548 KB Output is correct
10 Correct 2633 ms 29692 KB Output is correct
11 Correct 557 ms 68592 KB Output is correct
12 Correct 2641 ms 42736 KB Output is correct
13 Correct 6 ms 16984 KB Output is correct
14 Correct 2621 ms 28148 KB Output is correct
15 Correct 5 ms 16988 KB Output is correct
16 Correct 5 ms 16984 KB Output is correct
17 Correct 5 ms 16816 KB Output is correct
18 Correct 5 ms 16988 KB Output is correct
19 Correct 5 ms 16988 KB Output is correct
20 Correct 1340 ms 19080 KB Output is correct
21 Correct 5 ms 16988 KB Output is correct
22 Correct 5 ms 16988 KB Output is correct
23 Correct 6 ms 16892 KB Output is correct
24 Correct 5 ms 16988 KB Output is correct
25 Correct 8 ms 16988 KB Output is correct
26 Correct 6 ms 16988 KB Output is correct
27 Correct 5 ms 16828 KB Output is correct
28 Correct 5 ms 16988 KB Output is correct
29 Correct 5 ms 16988 KB Output is correct
30 Correct 6 ms 16988 KB Output is correct
31 Correct 6 ms 16988 KB Output is correct
32 Correct 17 ms 16984 KB Output is correct
33 Correct 21 ms 17244 KB Output is correct
34 Correct 6 ms 16836 KB Output is correct
35 Correct 6 ms 16988 KB Output is correct
36 Correct 2903 ms 70200 KB Output is correct
37 Correct 2680 ms 68588 KB Output is correct
38 Correct 287 ms 19216 KB Output is correct
39 Correct 34 ms 17496 KB Output is correct
40 Correct 33 ms 17500 KB Output is correct
41 Correct 11 ms 17244 KB Output is correct
42 Correct 2659 ms 39412 KB Output is correct
43 Correct 2619 ms 25860 KB Output is correct
44 Correct 2630 ms 29700 KB Output is correct
45 Correct 6 ms 16984 KB Output is correct
46 Correct 6 ms 16988 KB Output is correct
47 Correct 2656 ms 68092 KB Output is correct
48 Correct 2652 ms 64076 KB Output is correct
49 Correct 577 ms 46068 KB Output is correct
50 Correct 2660 ms 37880 KB Output is correct
51 Correct 2728 ms 53748 KB Output is correct
52 Correct 2716 ms 57380 KB Output is correct
53 Correct 190 ms 39936 KB Output is correct
54 Correct 2734 ms 54768 KB Output is correct
55 Correct 826 ms 80632 KB Output is correct
56 Correct 512 ms 58748 KB Output is correct
57 Correct 612 ms 70900 KB Output is correct
58 Correct 490 ms 42236 KB Output is correct
59 Correct 2307 ms 54776 KB Output is correct
60 Correct 2389 ms 54980 KB Output is correct
61 Incorrect 2709 ms 53768 KB Output isn't correct
62 Halted 0 ms 0 KB -