제출 #454577

#제출 시각아이디문제언어결과실행 시간메모리
454577sean617여행하는 상인 (APIO17_merchant)C++98
33 / 100
493 ms2448 KiB
#include <iostream> #include <cstdio> #include <vector> #define N 105 using namespace std; typedef long long ll; ll n, m, k, tc, M = 1e16, mx, B[N][1005], S[N][1005], di[N][N], ds[N], dt[N]; struct str { ll z, c1, c2; }; bool operator < (str p, str q) { return p.c1 * q.c2 < q.c1 * p.c2; } vector<str> a; int main() { ll i, j, t1, t2, t3, kk, us, ut; str t; cin >> n >> m >> k; for (i = 1; i <= n; i++) { for (j = 1; j <= k; j++) { scanf ("%lld %lld", &B[i][j], &S[i][j]); } } for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { di[i][j] = M; } di[i][i] = 0; } for (i = 0; i < m; i++) { scanf ("%lld %lld %lld", &t1, &t2, &t3); di[t1][t2] = min(di[t1][t2], t3); } for (kk = 1; kk <= n; kk++) { for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { di[i][j] = min(di[i][j], di[i][kk] +di[kk][j]); } } } for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { if (di[i][j] == M || i == j) continue; mx = -1; for (kk = 1; kk <= k; kk++) { if (B[i][kk] != -1 && S[j][kk] != -1 && S[j][kk] - B[i][kk] > 0) mx = max(mx, S[j][kk] - B[i][kk]); } a.push_back({i, j, (mx == -1 ? 0 : mx)}); } } mx = 0; for (tc = 1; tc <= n; tc++) { for (i = 1; i <= n; i++) {dt[i] = -1; ds[i] = -1;} dt[tc] = 0; ds[tc] = 0; for (j = 0; j <= n; j++) { for (i = 0; i < a.size(); i++) { t1 = a[i].z; t2 = a[i].c1; if (dt[t1] == -1) continue; ut = dt[t1] + di[t1][t2]; us = ds[t1] + a[i].c2; if (t2 == tc) mx = max(mx, us / ut); else { if (dt[t2] == -1 || us * dt[t2] > ut * ds[t2]) {ds[t2] = us; dt[t2] = ut;} } } } } cout << mx << endl; return 0; }

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

merchant.cpp: In function 'int main()':
merchant.cpp:59:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<str>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |    for (i = 0; i < a.size(); i++) {
      |                ~~^~~~~~~~~~
merchant.cpp:20:6: warning: unused variable 't' [-Wunused-variable]
   20 |  str t;
      |      ^
merchant.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |    scanf ("%lld %lld", &B[i][j], &S[i][j]);
      |    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:34:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |   scanf ("%lld %lld %lld", &t1, &t2, &t3);
      |   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...