답안 #906453

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
906453 2024-01-14T10:10:10 Z pcc Cheap flights (LMIO18_pigus_skrydziai) C++14
28 / 100
2910 ms 81140 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 6 ms 17240 KB Output is correct
2 Correct 5 ms 16988 KB Output is correct
3 Correct 6 ms 17016 KB Output is correct
4 Correct 5 ms 16984 KB Output is correct
5 Correct 5 ms 16988 KB Output is correct
6 Correct 1355 ms 19076 KB Output is correct
7 Correct 6 ms 16988 KB Output is correct
8 Correct 5 ms 16828 KB Output is correct
9 Correct 6 ms 16984 KB Output is correct
10 Correct 5 ms 16988 KB Output is correct
11 Correct 7 ms 16984 KB Output is correct
12 Correct 6 ms 16988 KB Output is correct
13 Correct 6 ms 16832 KB Output is correct
14 Correct 5 ms 16988 KB Output is correct
15 Correct 5 ms 16988 KB Output is correct
16 Correct 5 ms 16988 KB Output is correct
17 Correct 6 ms 16984 KB Output is correct
18 Correct 12 ms 16988 KB Output is correct
19 Correct 19 ms 17240 KB Output is correct
20 Correct 6 ms 16988 KB Output is correct
21 Correct 6 ms 16984 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 17240 KB Output is correct
2 Correct 5 ms 16988 KB Output is correct
3 Correct 6 ms 17016 KB Output is correct
4 Correct 5 ms 16984 KB Output is correct
5 Correct 5 ms 16988 KB Output is correct
6 Correct 1355 ms 19076 KB Output is correct
7 Correct 6 ms 16988 KB Output is correct
8 Correct 5 ms 16828 KB Output is correct
9 Correct 6 ms 16984 KB Output is correct
10 Correct 5 ms 16988 KB Output is correct
11 Correct 7 ms 16984 KB Output is correct
12 Correct 6 ms 16988 KB Output is correct
13 Correct 6 ms 16832 KB Output is correct
14 Correct 5 ms 16988 KB Output is correct
15 Correct 5 ms 16988 KB Output is correct
16 Correct 5 ms 16988 KB Output is correct
17 Correct 6 ms 16984 KB Output is correct
18 Correct 12 ms 16988 KB Output is correct
19 Correct 19 ms 17240 KB Output is correct
20 Correct 6 ms 16988 KB Output is correct
21 Correct 6 ms 16984 KB Output is correct
22 Correct 2910 ms 70124 KB Output is correct
23 Correct 2680 ms 68584 KB Output is correct
24 Correct 281 ms 19220 KB Output is correct
25 Correct 33 ms 17500 KB Output is correct
26 Correct 37 ms 17500 KB Output is correct
27 Correct 10 ms 17244 KB Output is correct
28 Correct 2671 ms 39344 KB Output is correct
29 Correct 2619 ms 26628 KB Output is correct
30 Correct 2633 ms 29696 KB Output is correct
31 Correct 7 ms 16988 KB Output is correct
32 Correct 7 ms 17080 KB Output is correct
33 Correct 2658 ms 68328 KB Output is correct
34 Incorrect 2657 ms 64240 KB Output isn't correct
35 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 338 ms 65824 KB Output is correct
2 Correct 866 ms 81140 KB Output is correct
3 Correct 240 ms 38700 KB Output is correct
4 Correct 504 ms 59136 KB Output is correct
5 Correct 1148 ms 69108 KB Output is correct
6 Correct 2627 ms 29696 KB Output is correct
7 Correct 503 ms 69556 KB Output is correct
8 Correct 619 ms 78832 KB Output is correct
9 Correct 8 ms 19548 KB Output is correct
10 Correct 2631 ms 29920 KB Output is correct
11 Correct 570 ms 67828 KB Output is correct
12 Correct 2640 ms 43000 KB Output is correct
13 Correct 5 ms 16988 KB Output is correct
14 Correct 2624 ms 27648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 338 ms 65824 KB Output is correct
2 Correct 866 ms 81140 KB Output is correct
3 Correct 240 ms 38700 KB Output is correct
4 Correct 504 ms 59136 KB Output is correct
5 Correct 1148 ms 69108 KB Output is correct
6 Correct 2627 ms 29696 KB Output is correct
7 Correct 503 ms 69556 KB Output is correct
8 Correct 619 ms 78832 KB Output is correct
9 Correct 8 ms 19548 KB Output is correct
10 Correct 2631 ms 29920 KB Output is correct
11 Correct 570 ms 67828 KB Output is correct
12 Correct 2640 ms 43000 KB Output is correct
13 Correct 5 ms 16988 KB Output is correct
14 Correct 2624 ms 27648 KB Output is correct
15 Correct 6 ms 17240 KB Output is correct
16 Correct 5 ms 16988 KB Output is correct
17 Correct 6 ms 17016 KB Output is correct
18 Correct 5 ms 16984 KB Output is correct
19 Correct 5 ms 16988 KB Output is correct
20 Correct 1355 ms 19076 KB Output is correct
21 Correct 6 ms 16988 KB Output is correct
22 Correct 5 ms 16828 KB Output is correct
23 Correct 6 ms 16984 KB Output is correct
24 Correct 5 ms 16988 KB Output is correct
25 Correct 7 ms 16984 KB Output is correct
26 Correct 6 ms 16988 KB Output is correct
27 Correct 6 ms 16832 KB Output is correct
28 Correct 5 ms 16988 KB Output is correct
29 Correct 5 ms 16988 KB Output is correct
30 Correct 5 ms 16988 KB Output is correct
31 Correct 6 ms 16984 KB Output is correct
32 Correct 12 ms 16988 KB Output is correct
33 Correct 19 ms 17240 KB Output is correct
34 Correct 6 ms 16988 KB Output is correct
35 Correct 6 ms 16984 KB Output is correct
36 Correct 2910 ms 70124 KB Output is correct
37 Correct 2680 ms 68584 KB Output is correct
38 Correct 281 ms 19220 KB Output is correct
39 Correct 33 ms 17500 KB Output is correct
40 Correct 37 ms 17500 KB Output is correct
41 Correct 10 ms 17244 KB Output is correct
42 Correct 2671 ms 39344 KB Output is correct
43 Correct 2619 ms 26628 KB Output is correct
44 Correct 2633 ms 29696 KB Output is correct
45 Correct 7 ms 16988 KB Output is correct
46 Correct 7 ms 17080 KB Output is correct
47 Correct 2658 ms 68328 KB Output is correct
48 Incorrect 2657 ms 64240 KB Output isn't correct
49 Halted 0 ms 0 KB -