Submission #416239

# Submission time Handle Problem Language Result Execution time Memory
416239 2021-06-02T08:19:14 Z Runtime_error_ Cheap flights (LMIO18_pigus_skrydziai) C++14
100 / 100
1798 ms 113420 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const ll inf = 3e5+9;
ll n,m,ans;
vector<pair<ll,ll> > adj[inf];
map<ll,ll> edge[inf];

int main(){
    scanf("%lld%lld",&n,&m);
    for(ll i=1;i<=m;i++){
        ll u,v,w;
        scanf("%lld%lld%lld",&u,&v,&w);
        adj[u].pb(mp(w,v));
        adj[v].pb(mp(w,u));
        edge[u][v] = edge[v][u] = w;
    }
    for(ll i=1;i<=n;i++){
        sort(adj[i].rbegin(),adj[i].rend());
        ll sum = 0;
        for(auto o:adj[i])
            sum += o.first;
        ans = max(ans,sum);
        if(adj[i].size() > 1){
            auto u = adj[i][0],v = adj[i][1];
            ans = max(ans,u.first+v.first+edge[u.second][v.second]);
        }
    }
    printf("%lld\n",ans);
}

Compilation message

pigus_skrydziai.cpp: In function 'int main()':
pigus_skrydziai.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%lld%lld",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
pigus_skrydziai.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         scanf("%lld%lld%lld",&u,&v,&w);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 13 ms 21372 KB Output is correct
2 Correct 13 ms 21328 KB Output is correct
3 Correct 13 ms 21324 KB Output is correct
4 Correct 13 ms 21380 KB Output is correct
5 Correct 13 ms 21440 KB Output is correct
6 Correct 30 ms 24904 KB Output is correct
7 Correct 13 ms 21452 KB Output is correct
8 Correct 15 ms 21428 KB Output is correct
9 Correct 13 ms 21452 KB Output is correct
10 Correct 15 ms 21424 KB Output is correct
11 Correct 14 ms 21564 KB Output is correct
12 Correct 13 ms 21436 KB Output is correct
13 Correct 13 ms 21456 KB Output is correct
14 Correct 13 ms 21444 KB Output is correct
15 Correct 13 ms 21328 KB Output is correct
16 Correct 12 ms 21324 KB Output is correct
17 Correct 13 ms 21412 KB Output is correct
18 Correct 14 ms 21572 KB Output is correct
19 Correct 15 ms 21828 KB Output is correct
20 Correct 13 ms 21440 KB Output is correct
21 Correct 13 ms 21324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 21372 KB Output is correct
2 Correct 13 ms 21328 KB Output is correct
3 Correct 13 ms 21324 KB Output is correct
4 Correct 13 ms 21380 KB Output is correct
5 Correct 13 ms 21440 KB Output is correct
6 Correct 30 ms 24904 KB Output is correct
7 Correct 13 ms 21452 KB Output is correct
8 Correct 15 ms 21428 KB Output is correct
9 Correct 13 ms 21452 KB Output is correct
10 Correct 15 ms 21424 KB Output is correct
11 Correct 14 ms 21564 KB Output is correct
12 Correct 13 ms 21436 KB Output is correct
13 Correct 13 ms 21456 KB Output is correct
14 Correct 13 ms 21444 KB Output is correct
15 Correct 13 ms 21328 KB Output is correct
16 Correct 12 ms 21324 KB Output is correct
17 Correct 13 ms 21412 KB Output is correct
18 Correct 14 ms 21572 KB Output is correct
19 Correct 15 ms 21828 KB Output is correct
20 Correct 13 ms 21440 KB Output is correct
21 Correct 13 ms 21324 KB Output is correct
22 Correct 1798 ms 113420 KB Output is correct
23 Correct 578 ms 108740 KB Output is correct
24 Correct 37 ms 25200 KB Output is correct
25 Correct 19 ms 22596 KB Output is correct
26 Correct 20 ms 22628 KB Output is correct
27 Correct 16 ms 21952 KB Output is correct
28 Correct 545 ms 58224 KB Output is correct
29 Correct 162 ms 35652 KB Output is correct
30 Correct 332 ms 43264 KB Output is correct
31 Correct 14 ms 21580 KB Output is correct
32 Correct 14 ms 21608 KB Output is correct
33 Correct 695 ms 111024 KB Output is correct
34 Correct 511 ms 101844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 240 ms 51796 KB Output is correct
2 Correct 757 ms 97572 KB Output is correct
3 Correct 219 ms 46656 KB Output is correct
4 Correct 451 ms 70132 KB Output is correct
5 Correct 957 ms 88948 KB Output is correct
6 Correct 143 ms 42308 KB Output is correct
7 Correct 205 ms 79912 KB Output is correct
8 Correct 240 ms 77520 KB Output is correct
9 Correct 18 ms 21580 KB Output is correct
10 Correct 130 ms 42380 KB Output is correct
11 Correct 284 ms 78388 KB Output is correct
12 Correct 271 ms 63240 KB Output is correct
13 Correct 15 ms 21436 KB Output is correct
14 Correct 252 ms 39348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 240 ms 51796 KB Output is correct
2 Correct 757 ms 97572 KB Output is correct
3 Correct 219 ms 46656 KB Output is correct
4 Correct 451 ms 70132 KB Output is correct
5 Correct 957 ms 88948 KB Output is correct
6 Correct 143 ms 42308 KB Output is correct
7 Correct 205 ms 79912 KB Output is correct
8 Correct 240 ms 77520 KB Output is correct
9 Correct 18 ms 21580 KB Output is correct
10 Correct 130 ms 42380 KB Output is correct
11 Correct 284 ms 78388 KB Output is correct
12 Correct 271 ms 63240 KB Output is correct
13 Correct 15 ms 21436 KB Output is correct
14 Correct 252 ms 39348 KB Output is correct
15 Correct 13 ms 21372 KB Output is correct
16 Correct 13 ms 21328 KB Output is correct
17 Correct 13 ms 21324 KB Output is correct
18 Correct 13 ms 21380 KB Output is correct
19 Correct 13 ms 21440 KB Output is correct
20 Correct 30 ms 24904 KB Output is correct
21 Correct 13 ms 21452 KB Output is correct
22 Correct 15 ms 21428 KB Output is correct
23 Correct 13 ms 21452 KB Output is correct
24 Correct 15 ms 21424 KB Output is correct
25 Correct 14 ms 21564 KB Output is correct
26 Correct 13 ms 21436 KB Output is correct
27 Correct 13 ms 21456 KB Output is correct
28 Correct 13 ms 21444 KB Output is correct
29 Correct 13 ms 21328 KB Output is correct
30 Correct 12 ms 21324 KB Output is correct
31 Correct 13 ms 21412 KB Output is correct
32 Correct 14 ms 21572 KB Output is correct
33 Correct 15 ms 21828 KB Output is correct
34 Correct 13 ms 21440 KB Output is correct
35 Correct 13 ms 21324 KB Output is correct
36 Correct 1798 ms 113420 KB Output is correct
37 Correct 578 ms 108740 KB Output is correct
38 Correct 37 ms 25200 KB Output is correct
39 Correct 19 ms 22596 KB Output is correct
40 Correct 20 ms 22628 KB Output is correct
41 Correct 16 ms 21952 KB Output is correct
42 Correct 545 ms 58224 KB Output is correct
43 Correct 162 ms 35652 KB Output is correct
44 Correct 332 ms 43264 KB Output is correct
45 Correct 14 ms 21580 KB Output is correct
46 Correct 14 ms 21608 KB Output is correct
47 Correct 695 ms 111024 KB Output is correct
48 Correct 511 ms 101844 KB Output is correct
49 Correct 587 ms 59972 KB Output is correct
50 Correct 631 ms 57924 KB Output is correct
51 Correct 778 ms 62380 KB Output is correct
52 Correct 952 ms 72848 KB Output is correct
53 Correct 262 ms 40368 KB Output is correct
54 Correct 1006 ms 78636 KB Output is correct
55 Correct 643 ms 100292 KB Output is correct
56 Correct 422 ms 73688 KB Output is correct
57 Correct 666 ms 71788 KB Output is correct
58 Correct 370 ms 49808 KB Output is correct
59 Correct 760 ms 80084 KB Output is correct
60 Correct 784 ms 74764 KB Output is correct
61 Correct 932 ms 72448 KB Output is correct