Submission #540809

#TimeUsernameProblemLanguageResultExecution timeMemory
540809LucaDantasTravelling Merchant (APIO17_merchant)C++17
12 / 100
29 ms1488 KiB
#include <bits/stdc++.h> using namespace std; constexpr int maxn = 110, maxk = 1010, inf = 0x3f3f3f3f; int valor[maxn][maxn]; // grafo completo final int dp[maxn][maxn]; // floyd warshall int b[maxn][maxk], s[maxn][maxk]; int main() { int n, m, k; scanf("%d %d %d", &n, &m, &k); memset(dp, 0x3f, sizeof dp); 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++) { int a, b, w; scanf("%d %d %d", &a, &b, &w); dp[a][b] = w; } for(int l = 1; l <= n; l++) for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) if(dp[i][l] < inf && dp[l][j] < inf) dp[i][j] = min(dp[i][j], dp[i][l] + dp[l][j]); for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) for(int l = 1; l <= k; l++) valor[i][j] = max(valor[i][j], -b[i][l] +s[j][l]); // compro 'l' em 'i' e vendo em 'j' /* for(int i = 2; i <= n; i++) printf("%d %d %d\n", valor[1][i], dp[1][i], dp[i][1]); */ int ans = 0; for(int i = 2; i <= n; i++) ans = max(ans, valor[1][i] / (dp[1][i] + dp[i][1])); printf("%d\n", ans); }

Compilation message (stderr)

merchant.cpp: In function 'int main()':
merchant.cpp:12:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  int n, m, k; scanf("%d %d %d", &n, &m, &k);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:17:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |    scanf("%d %d", &b[i][j], &s[i][j]);
      |    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:20:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   int a, b, w; scanf("%d %d %d", &a, &b, &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...