Submission #50089

#TimeUsernameProblemLanguageResultExecution timeMemory
50089mohammad_kilaniTravelling Merchant (APIO17_merchant)C++17
0 / 100
30 ms520 KiB
#include <bits/stdc++.h> using namespace std; #define mod 1000000007 #define oo 1000000000 const int N = 150; int dist[N][N] ; int b[N][N] , s[N][N]; int n , m , k , u , v , w; int main() { scanf("%d%d%d",&n,&m,&k); for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(i != j) dist[i][j] = oo; } } for(int i=1;i<=n;i++){ for(int j=1;j<=k;j++){ scanf("%d%d",&b[i][j],&s[i][j]); } } for(int i=0;i<m;i++){ scanf("%d%d%d",&u,&v,&w); dist[u][v] = min(dist[u][v],w); } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ for(int k=1;k<=n;k++){ dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]); } } } long long ans = 0; for(int i=2;i<=n;i++){ for(int j=1;j<=k;j++){ if(s[i][j] != -1 && b[1][j] != -1 && dist[1][i] != oo && dist[i][1] != oo) ans = max(ans, (long long)(s[i][j] - b[1][j]) / (dist[1][i] + dist[i][1])); } } int diss = oo ; for(int i=2;i<=n;i++){ diss = min(diss,dist[1][i] + dist[i][1]); } int dis2 = 0; for(int i=1;i<=k;i++){ if(b[1][i] != -1 && s[1][i] != -1) dis2 = max(dis2,(s[1][i] - b[1][i])); } ans = max(ans, (long long)dis2 / diss); cout << ans << endl; return 0; }

Compilation message (stderr)

merchant.cpp: In function 'int main()':
merchant.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&n,&m,&k);
     ~~~~~^~~~~~~~~~~~~~~~~~~
merchant.cpp:19:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d%d",&b[i][j],&s[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d",&u,&v,&w);
         ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...