Submission #906452

# Submission time Handle Problem Language Result Execution time Memory
906452 2024-01-14T10:09:39 Z pcc Cheap flights (LMIO18_pigus_skrydziai) C++14
28 / 100
3000 ms 80264 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.7*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;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 16984 KB Output is correct
2 Correct 5 ms 16988 KB Output is correct
3 Correct 5 ms 16988 KB Output is correct
4 Correct 5 ms 16988 KB Output is correct
5 Correct 5 ms 16988 KB Output is correct
6 Correct 1300 ms 19324 KB Output is correct
7 Correct 7 ms 16988 KB Output is correct
8 Correct 5 ms 16988 KB Output is correct
9 Correct 5 ms 17040 KB Output is correct
10 Correct 5 ms 16988 KB Output is correct
11 Correct 7 ms 16988 KB Output is correct
12 Correct 6 ms 16984 KB Output is correct
13 Correct 6 ms 16988 KB Output is correct
14 Correct 5 ms 16988 KB Output is correct
15 Correct 6 ms 16988 KB Output is correct
16 Correct 5 ms 16988 KB Output is correct
17 Correct 6 ms 17028 KB Output is correct
18 Correct 12 ms 16984 KB Output is correct
19 Correct 19 ms 17244 KB Output is correct
20 Correct 7 ms 16984 KB Output is correct
21 Correct 5 ms 16988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 16984 KB Output is correct
2 Correct 5 ms 16988 KB Output is correct
3 Correct 5 ms 16988 KB Output is correct
4 Correct 5 ms 16988 KB Output is correct
5 Correct 5 ms 16988 KB Output is correct
6 Correct 1300 ms 19324 KB Output is correct
7 Correct 7 ms 16988 KB Output is correct
8 Correct 5 ms 16988 KB Output is correct
9 Correct 5 ms 17040 KB Output is correct
10 Correct 5 ms 16988 KB Output is correct
11 Correct 7 ms 16988 KB Output is correct
12 Correct 6 ms 16984 KB Output is correct
13 Correct 6 ms 16988 KB Output is correct
14 Correct 5 ms 16988 KB Output is correct
15 Correct 6 ms 16988 KB Output is correct
16 Correct 5 ms 16988 KB Output is correct
17 Correct 6 ms 17028 KB Output is correct
18 Correct 12 ms 16984 KB Output is correct
19 Correct 19 ms 17244 KB Output is correct
20 Correct 7 ms 16984 KB Output is correct
21 Correct 5 ms 16988 KB Output is correct
22 Execution timed out 3009 ms 70172 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 346 ms 65800 KB Output is correct
2 Correct 868 ms 80264 KB Output is correct
3 Correct 265 ms 39168 KB Output is correct
4 Correct 549 ms 59180 KB Output is correct
5 Correct 1256 ms 68528 KB Output is correct
6 Correct 2729 ms 29696 KB Output is correct
7 Correct 515 ms 69468 KB Output is correct
8 Correct 635 ms 78372 KB Output is correct
9 Correct 10 ms 19548 KB Output is correct
10 Correct 2732 ms 29892 KB Output is correct
11 Correct 575 ms 67960 KB Output is correct
12 Correct 2737 ms 42996 KB Output is correct
13 Correct 5 ms 16984 KB Output is correct
14 Correct 2719 ms 27652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 346 ms 65800 KB Output is correct
2 Correct 868 ms 80264 KB Output is correct
3 Correct 265 ms 39168 KB Output is correct
4 Correct 549 ms 59180 KB Output is correct
5 Correct 1256 ms 68528 KB Output is correct
6 Correct 2729 ms 29696 KB Output is correct
7 Correct 515 ms 69468 KB Output is correct
8 Correct 635 ms 78372 KB Output is correct
9 Correct 10 ms 19548 KB Output is correct
10 Correct 2732 ms 29892 KB Output is correct
11 Correct 575 ms 67960 KB Output is correct
12 Correct 2737 ms 42996 KB Output is correct
13 Correct 5 ms 16984 KB Output is correct
14 Correct 2719 ms 27652 KB Output is correct
15 Correct 5 ms 16984 KB Output is correct
16 Correct 5 ms 16988 KB Output is correct
17 Correct 5 ms 16988 KB Output is correct
18 Correct 5 ms 16988 KB Output is correct
19 Correct 5 ms 16988 KB Output is correct
20 Correct 1300 ms 19324 KB Output is correct
21 Correct 7 ms 16988 KB Output is correct
22 Correct 5 ms 16988 KB Output is correct
23 Correct 5 ms 17040 KB Output is correct
24 Correct 5 ms 16988 KB Output is correct
25 Correct 7 ms 16988 KB Output is correct
26 Correct 6 ms 16984 KB Output is correct
27 Correct 6 ms 16988 KB Output is correct
28 Correct 5 ms 16988 KB Output is correct
29 Correct 6 ms 16988 KB Output is correct
30 Correct 5 ms 16988 KB Output is correct
31 Correct 6 ms 17028 KB Output is correct
32 Correct 12 ms 16984 KB Output is correct
33 Correct 19 ms 17244 KB Output is correct
34 Correct 7 ms 16984 KB Output is correct
35 Correct 5 ms 16988 KB Output is correct
36 Execution timed out 3009 ms 70172 KB Time limit exceeded
37 Halted 0 ms 0 KB -