Submission #256138

# Submission time Handle Problem Language Result Execution time Memory
256138 2020-08-02T10:16:14 Z aloo123 Cheap flights (LMIO18_pigus_skrydziai) C++14
28 / 100
3000 ms 140252 KB
		#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = 1e12;
const ll N =(3e5+5); // TODO : change value as per problem
const ll MOD = 1e9+7;
set<pair<int,int>> adj2[N];
map<pll,ll> cost;
void solve(){
	int n,m;
	cin >> n >> m;
	for(int i =1;i<=m;i++){
		int u,v;
		int ch;
		cin >> u >> v >> ch;
		adj2[u].in({ch,v});
		adj2[v].in({ch,u});
		cost[{u,v}] = ch;
		cost[{v,u}] = ch;
	}	
	int ans = 0;
	for(int i =1 ;i<=n;i++){
		int cur = 0;
		if((int)adj2[i].size() < 2) continue;
		auto it = (adj2[i].rbegin());
		// it--;
		// auto it2 = it-1;
		pll p = *(it);
		int u = p.s;
		cur += p.f;
		adj2[i].erase(p);

		// it++;
		pll p2 = *(it);
		int v = p2.s;
		cur += p2.f;
		adj2[i].in(p);
		cur += cost[{u,v}];
		ans = max(ans,cur);
	}	
	for(int i =1;i<=n;i++){
		int cur = 0;
		for(auto p:adj2[i]){
			cur += p.f;
		}
		ans = max(ans,cur);
	}
	cout << ans << endl;
	


}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}
# Verdict Execution time Memory Grader output
1 Correct 9 ms 14464 KB Output is correct
2 Correct 9 ms 14464 KB Output is correct
3 Correct 9 ms 14464 KB Output is correct
4 Correct 10 ms 14464 KB Output is correct
5 Correct 9 ms 14464 KB Output is correct
6 Correct 42 ms 19680 KB Output is correct
7 Correct 9 ms 14464 KB Output is correct
8 Correct 9 ms 14464 KB Output is correct
9 Correct 9 ms 14464 KB Output is correct
10 Correct 11 ms 14464 KB Output is correct
11 Correct 9 ms 14592 KB Output is correct
12 Correct 9 ms 14464 KB Output is correct
13 Correct 9 ms 14464 KB Output is correct
14 Correct 9 ms 14464 KB Output is correct
15 Correct 9 ms 14464 KB Output is correct
16 Correct 9 ms 14464 KB Output is correct
17 Correct 10 ms 14464 KB Output is correct
18 Correct 10 ms 14720 KB Output is correct
19 Correct 14 ms 14976 KB Output is correct
20 Correct 9 ms 14464 KB Output is correct
21 Correct 9 ms 14464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 14464 KB Output is correct
2 Correct 9 ms 14464 KB Output is correct
3 Correct 9 ms 14464 KB Output is correct
4 Correct 10 ms 14464 KB Output is correct
5 Correct 9 ms 14464 KB Output is correct
6 Correct 42 ms 19680 KB Output is correct
7 Correct 9 ms 14464 KB Output is correct
8 Correct 9 ms 14464 KB Output is correct
9 Correct 9 ms 14464 KB Output is correct
10 Correct 11 ms 14464 KB Output is correct
11 Correct 9 ms 14592 KB Output is correct
12 Correct 9 ms 14464 KB Output is correct
13 Correct 9 ms 14464 KB Output is correct
14 Correct 9 ms 14464 KB Output is correct
15 Correct 9 ms 14464 KB Output is correct
16 Correct 9 ms 14464 KB Output is correct
17 Correct 10 ms 14464 KB Output is correct
18 Correct 10 ms 14720 KB Output is correct
19 Correct 14 ms 14976 KB Output is correct
20 Correct 9 ms 14464 KB Output is correct
21 Correct 9 ms 14464 KB Output is correct
22 Execution timed out 3048 ms 140252 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 327 ms 52332 KB Output is correct
2 Correct 872 ms 108644 KB Output is correct
3 Correct 243 ms 45944 KB Output is correct
4 Correct 537 ms 74556 KB Output is correct
5 Correct 1287 ms 99960 KB Output is correct
6 Correct 223 ms 45864 KB Output is correct
7 Correct 351 ms 89464 KB Output is correct
8 Correct 402 ms 89976 KB Output is correct
9 Correct 17 ms 14720 KB Output is correct
10 Correct 267 ms 45948 KB Output is correct
11 Correct 591 ms 89836 KB Output is correct
12 Correct 542 ms 77304 KB Output is correct
13 Correct 9 ms 14464 KB Output is correct
14 Correct 292 ms 39800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 327 ms 52332 KB Output is correct
2 Correct 872 ms 108644 KB Output is correct
3 Correct 243 ms 45944 KB Output is correct
4 Correct 537 ms 74556 KB Output is correct
5 Correct 1287 ms 99960 KB Output is correct
6 Correct 223 ms 45864 KB Output is correct
7 Correct 351 ms 89464 KB Output is correct
8 Correct 402 ms 89976 KB Output is correct
9 Correct 17 ms 14720 KB Output is correct
10 Correct 267 ms 45948 KB Output is correct
11 Correct 591 ms 89836 KB Output is correct
12 Correct 542 ms 77304 KB Output is correct
13 Correct 9 ms 14464 KB Output is correct
14 Correct 292 ms 39800 KB Output is correct
15 Correct 916 ms 64976 KB Output is correct
16 Correct 942 ms 63860 KB Output is correct
17 Correct 890 ms 71160 KB Output is correct
18 Correct 1328 ms 86040 KB Output is correct
19 Correct 288 ms 39416 KB Output is correct
20 Correct 1190 ms 89900 KB Output is correct
21 Correct 841 ms 108632 KB Output is correct
22 Correct 548 ms 77268 KB Output is correct
23 Correct 737 ms 80416 KB Output is correct
24 Correct 524 ms 52232 KB Output is correct
25 Correct 1295 ms 90476 KB Output is correct
26 Correct 1372 ms 87416 KB Output is correct
27 Correct 1628 ms 87584 KB Output is correct
28 Correct 9 ms 14464 KB Output is correct
29 Correct 9 ms 14464 KB Output is correct
30 Correct 9 ms 14464 KB Output is correct
31 Correct 10 ms 14464 KB Output is correct
32 Correct 9 ms 14464 KB Output is correct
33 Correct 42 ms 19680 KB Output is correct
34 Correct 9 ms 14464 KB Output is correct
35 Correct 9 ms 14464 KB Output is correct
36 Correct 9 ms 14464 KB Output is correct
37 Correct 11 ms 14464 KB Output is correct
38 Correct 9 ms 14592 KB Output is correct
39 Correct 9 ms 14464 KB Output is correct
40 Correct 9 ms 14464 KB Output is correct
41 Correct 9 ms 14464 KB Output is correct
42 Correct 9 ms 14464 KB Output is correct
43 Correct 9 ms 14464 KB Output is correct
44 Correct 10 ms 14464 KB Output is correct
45 Correct 10 ms 14720 KB Output is correct
46 Correct 14 ms 14976 KB Output is correct
47 Correct 9 ms 14464 KB Output is correct
48 Correct 9 ms 14464 KB Output is correct
49 Execution timed out 3048 ms 140252 KB Time limit exceeded
50 Halted 0 ms 0 KB -