Submission #392515

# Submission time Handle Problem Language Result Execution time Memory
392515 2021-04-21T09:34:38 Z keta_tsimakuridze Cheap flights (LMIO18_pigus_skrydziai) C++14
37 / 100
1640 ms 106380 KB
#include<bits/stdc++.h>
#define f first
#define int long long
#define s second
using namespace std;
const int N=2e5+5,mod=1e9+7;
int t,n,m;
map<int,int> f[N];
vector<pair<int,int> >V[N];
string s;
 main(){
	// t=1;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int u,v,w;
		cin>>u>>v>>w;
		V[u].push_back({w,v});
		V[v].push_back({w,u});
		f[u][v]=f[v][u]=w;
	}
	int ans = 0;
	for(int u=1;u<=n;u++){
		sort(V[u].begin(),V[u].end());
		reverse(V[u].begin(),V[u].end());
		int sum=0;
		for(int j=0;j<V[u].size();j++){
			sum += V[u][j].f;
		}
		if(V[u].size()>1) ans=max(ans,V[u][0].f+V[u][1].f+f[V[u][0].s][V[u][1].s]);
		ans=max(ans,sum);
	}
	cout<<ans;
}

Compilation message

pigus_skrydziai.cpp:11:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 |  main(){
      |       ^
pigus_skrydziai.cpp: In function 'int main()':
pigus_skrydziai.cpp:26:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for(int j=0;j<V[u].size();j++){
      |               ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 14284 KB Output is correct
2 Correct 11 ms 14284 KB Output is correct
3 Correct 10 ms 14284 KB Output is correct
4 Correct 11 ms 14284 KB Output is correct
5 Correct 9 ms 14356 KB Output is correct
6 Correct 41 ms 17860 KB Output is correct
7 Correct 11 ms 14408 KB Output is correct
8 Correct 9 ms 14284 KB Output is correct
9 Correct 10 ms 14412 KB Output is correct
10 Correct 9 ms 14388 KB Output is correct
11 Correct 10 ms 14412 KB Output is correct
12 Correct 10 ms 14392 KB Output is correct
13 Correct 10 ms 14416 KB Output is correct
14 Correct 10 ms 14284 KB Output is correct
15 Correct 10 ms 14284 KB Output is correct
16 Correct 9 ms 14284 KB Output is correct
17 Correct 9 ms 14284 KB Output is correct
18 Correct 11 ms 14552 KB Output is correct
19 Correct 12 ms 14668 KB Output is correct
20 Correct 10 ms 14412 KB Output is correct
21 Correct 9 ms 14284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 14284 KB Output is correct
2 Correct 11 ms 14284 KB Output is correct
3 Correct 10 ms 14284 KB Output is correct
4 Correct 11 ms 14284 KB Output is correct
5 Correct 9 ms 14356 KB Output is correct
6 Correct 41 ms 17860 KB Output is correct
7 Correct 11 ms 14408 KB Output is correct
8 Correct 9 ms 14284 KB Output is correct
9 Correct 10 ms 14412 KB Output is correct
10 Correct 9 ms 14388 KB Output is correct
11 Correct 10 ms 14412 KB Output is correct
12 Correct 10 ms 14392 KB Output is correct
13 Correct 10 ms 14416 KB Output is correct
14 Correct 10 ms 14284 KB Output is correct
15 Correct 10 ms 14284 KB Output is correct
16 Correct 9 ms 14284 KB Output is correct
17 Correct 9 ms 14284 KB Output is correct
18 Correct 11 ms 14552 KB Output is correct
19 Correct 12 ms 14668 KB Output is correct
20 Correct 10 ms 14412 KB Output is correct
21 Correct 9 ms 14284 KB Output is correct
22 Correct 1640 ms 106380 KB Output is correct
23 Correct 872 ms 101752 KB Output is correct
24 Correct 44 ms 18240 KB Output is correct
25 Correct 20 ms 15584 KB Output is correct
26 Correct 21 ms 15476 KB Output is correct
27 Correct 15 ms 14928 KB Output is correct
28 Correct 636 ms 51104 KB Output is correct
29 Correct 204 ms 28736 KB Output is correct
30 Correct 388 ms 36200 KB Output is correct
31 Correct 11 ms 14540 KB Output is correct
32 Correct 10 ms 14524 KB Output is correct
33 Correct 805 ms 103988 KB Output is correct
34 Correct 605 ms 94632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 28932 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 28932 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -