제출 #99898

#제출 시각아이디문제언어결과실행 시간메모리
99898TadijaSebez여행하는 상인 (APIO17_merchant)C++11
100 / 100
104 ms1528 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const ll inf=1e18; const int N=105; const int K=1050; int b[N][K],s[N][K],p[N][N]; ll dist[N][N],work[N][N]; int main() { int n,m,k,u,v; scanf("%i %i %i",&n,&m,&k); for(int i=1;i<=n;i++) for(int j=1;j<=k;j++) scanf("%i %i",&b[i][j],&s[i][j]); for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) for(int l=1;l<=k;l++) if(b[i][l]!=-1 && s[j][l]!=-1) p[i][j]=max(p[i][j],s[j][l]-b[i][l]); for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) dist[i][j]=inf; for(int i=1;i<=m;i++) scanf("%i %i",&u,&v),scanf("%lld",&dist[u][v]); for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) for(int l=1;l<=n;l++) dist[j][l]=min(dist[j][l],dist[j][i]+dist[i][l]); int top=1e9,bot=1,mid,ans=0; while(top>=bot) { mid=top+bot>>1; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) work[i][j]=(ll)mid*min(dist[i][j],inf/mid)-p[i][j]; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) for(int l=1;l<=n;l++) work[j][l]=min(work[j][l],work[j][i]+work[i][l]); bool ok=0;for(int i=1;i<=n;i++) ok|=work[i][i]<=0; if(ok) ans=mid,bot=mid+1; else top=mid-1; } printf("%i\n",ans); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

merchant.cpp: In function 'int main()':
merchant.cpp:21:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   mid=top+bot>>1;
       ~~~^~~~
merchant.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i %i",&n,&m,&k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
merchant.cpp:13:51: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) for(int j=1;j<=k;j++) scanf("%i %i",&b[i][j],&s[i][j]);
                                              ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:16:44: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=m;i++) scanf("%i %i",&u,&v),scanf("%lld",&dist[u][v]);
                        ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:16:44: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...