Submission #258785

# Submission time Handle Problem Language Result Execution time Memory
258785 2020-08-06T14:42:25 Z uacoder123 Cheap flights (LMIO18_pigus_skrydziai) C++14
0 / 100
972 ms 64736 KB
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)
#define pb(a) push_back(a)
#define bit(x,b) (x&(1LL<<b))

typedef long long int lli;
typedef pair <lli,lli> ii;
typedef pair <ii,lli> iii;
typedef vector <lli> vi;
map<ii,int> ma;
vector<ii> al[300001];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;++i)
    {
        int f,s,w;
        cin>>f>>s>>w;
        al[f].pb(mp(w,s));
        al[s].pb(mp(w,f));
        ma[mp(f,s)]=w;
        ma[mp(s,f)]=w;
    }
    lli ans=0;
    for(int i=1;i<=n;++i)
    {
        sort(all(al[i]));
        lli s=0;
        for(int j=0;j<al[i].size();++j)
            s+=al[i][j].F;
        if(al[i].size()>1&&ma.find(mp(al[i][0].F,al[i][1].F))!=ma.end())
            s=max(s,al[i][0].F+al[i][1].F+ma[mp(al[i][0].F,al[i][1].F)]);
        ans=max(ans,s);
    }
    cout<<ans<<endl;
    return(0);
} 

Compilation message

pigus_skrydziai.cpp: In function 'int main()':
pigus_skrydziai.cpp:37:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0;j<al[i].size();++j)
                     ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7296 KB Output is correct
2 Incorrect 5 ms 7296 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7296 KB Output is correct
2 Incorrect 5 ms 7296 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 413 ms 37752 KB Output is correct
2 Correct 972 ms 64736 KB Output is correct
3 Incorrect 289 ms 26360 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 413 ms 37752 KB Output is correct
2 Correct 972 ms 64736 KB Output is correct
3 Incorrect 289 ms 26360 KB Output isn't correct
4 Halted 0 ms 0 KB -