Submission #1113860

#TimeUsernameProblemLanguageResultExecution timeMemory
1113860adkjtTravelling Merchant (APIO17_merchant)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define pii pair<long long,long long> #define f first #define s second #define ll long long //vector<pii> g[111]; ll dis[111][111],a[111][111],f[111][111]; ll buy[111][1111],sell[111][1111]; int main() { int n,m,k; cin>>n>>m>>k; for(int i=1; i<=n; i++) { for(int j=1; j<=k; j++) cin>>buy[i][j]>>sell[i][j]; for(int j=1; j<=n; j++) dis[i][j]=1e18; } for(int i=1; i<=m; i++) { int u,v,w; cin>>u>>v>>w; dis[u][v]=w; } for(int K=1; K<=n; K++) { for(int i=1; i<=n; i++) { for(int j=1; j<=n; j++) { dis[i][j]=min(dis[i][j],dis[i][K]+dis[K][j]); } } } for(int i=1; i<=n; i++) for(int K=1; K<=n; K++) for(int j=1; j<=k; j++) { if(buy[i][j]!=-1&&sell[K][j]!=-1) a[i][K]=max(a[i][K],sell[K][j]-buy[i][j]); } ll l=0,r=1e9,ans=0; while(l<r) { ll mid=(l+r)/2; for(int i=1; i<=n; i++) { for(int j=1; j<=n; j++) f[i][j]=min(1000000000000000,mid*dis[i][j])-a[i][j]; } for(int K=1; K<=n; K++) { for(int i=1; i<=n; i++) { for(int j=1; j<=n; j++) { f[i][j]=min(f[i][j],f[i][K]+f[K][j]); } } } bool ch=0; for(int i=1; i<=n; i++) { if(f[i][i]<=0) { ch=1; } } if(ch) ans=mid,l=mid+1; else r=mid-1; } cout<<ans; }

Compilation message (stderr)

merchant.cpp: In function 'int main()':
merchant.cpp:54:59: error: no matching function for call to 'min(long int, long long int)'
   54 |                 f[i][j]=min(1000000000000000,mid*dis[i][j])-a[i][j];
      |                                                           ^
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:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
merchant.cpp:54:59: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   54 |                 f[i][j]=min(1000000000000000,mid*dis[i][j])-a[i][j];
      |                                                           ^
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:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
merchant.cpp:54:59: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   54 |                 f[i][j]=min(1000000000000000,mid*dis[i][j])-a[i][j];
      |                                                           ^
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:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
merchant.cpp:54:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   54 |                 f[i][j]=min(1000000000000000,mid*dis[i][j])-a[i][j];
      |                                                           ^
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:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
merchant.cpp:54:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   54 |                 f[i][j]=min(1000000000000000,mid*dis[i][j])-a[i][j];
      |                                                           ^