Submission #533457

#TimeUsernameProblemLanguageResultExecution timeMemory
533457ohohorzTravelling Merchant (APIO17_merchant)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define f first
// #define s second
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define vi vector<int>

const int N = 100 + 5;
const int INF = 1e18;
const int MOD = 998244353;
const int BLOCKSZ = 318;
const int K = 1005;

int binpow(int a, int b){
    if(b == 0) return 1;
    if(b%2==0){
        int x = binpow(a, b >> 1LL);
        return (x%MOD*x%MOD)%MOD;
    }
    int x = binpow(a, b - 1);
    return (x%MOD*a%MOD)%MOD;
}
int b[N][K], s[N][K],dist[N][N];

void solve(){
    
    int n, m, k;
    cin >> n >> m >> k;
    for(int i =1;i<=n;i++){
        for(int j =1;j<=k;j++) cin >> b[i][j];
        for(int j =1;j<=k;j++) cin >> s[i][j];
    }
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=n;j++){
            dist[i][j] = INF;
        }
        dist[i][i] = 0;
    }
    for(int i =1;i<=m;i++){
        int u, v, d;
        cin >> u >> v >> d;
        dist[u][v] = d;
    }
    for(int k = 1;k <= n;k++){
        for(int i = 1;i <= n;i++){
            for(int j = 1;j <= n;j++){
                if(dist[i][k] < INF and dist[k][j] < INF)
                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    pii best;// {profit, path length}
    best = mp(-INF, -INF);
    bool first = 1;
    for(int i = 2;i <= n;i++){
        if(dist[1][i] == INF or dist[i][1] == INF) continue;

        int path = dist[1][i] + dist[i][1];

        int profit = -INF;
        for(int j =1;j<=k;j++){
            if(s[i][j] != -1 and b[1][j] != -1)
                profit = max(s[i][j] - b[1][j], profit);
        }
        if(profit == -INF) continue;
        // cout << i <<" "<<dist[1][i]<<" + "<<dist[i][1]<<" "<<profit<<"\n";

        if(first == 1){
            best = mp(profit, path);
            first =0;
        }else{
            if((profit * best.second) > (path * best.first))
                best = mp(profit, path);
        }
    }
    if(first == 1) cout << 0 << "\n";
    else cout << max(best.f / best.second) << "\n";




}
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(0);
    
    int tc=1;
    // cin >> tc;
    while(tc--){
        solve();
    }

    
    

}
/*
4 5 1
5 4
-1 6
-1 100
-1 5
1 2 3
2 3 3
1 4 1
4 3 1
3 1 1
*/

Compilation message (stderr)

merchant.cpp: In function 'void solve()':
merchant.cpp:82:42: error: no matching function for call to 'max(long long int)'
   82 |     else cout << max(best.f / best.second) << "\n";
      |                                          ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from merchant.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
merchant.cpp:82:42: note:   candidate expects 2 arguments, 1 provided
   82 |     else cout << max(best.f / best.second) << "\n";
      |                                          ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from merchant.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
merchant.cpp:82:42: note:   candidate expects 3 arguments, 1 provided
   82 |     else cout << max(best.f / best.second) << "\n";
      |                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from merchant.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
merchant.cpp:82:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   82 |     else cout << max(best.f / best.second) << "\n";
      |                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from merchant.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
merchant.cpp:82:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   82 |     else cout << max(best.f / best.second) << "\n";
      |                                          ^