# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
156999 | 2019-10-09T02:06:13 Z | Mercenary | 여행하는 상인 (APIO17_merchant) | C++14 | 45 ms | 760 KB |
#include<bits/stdc++.h> #define taskname "A" #define pb push_back #define mp make_pair #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef pair<ll,ll> ii; #define next aoisfdhjaoif const int maxn = 1e2 + 5; const int mod = 1e9 + 7; const ll inf = 1e11 + 1; int n , m , k; int s[maxn][maxn] , b[maxn][maxn]; int profit[maxn][maxn]; ll dis[maxn][maxn]; ll dis1[maxn][maxn]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); if(fopen(taskname".INP","r")){ freopen(taskname".INP","r",stdin); freopen(taskname".OUT","w",stdout); } cin >> n >> m >> k; for(int i = 1 ; i <= n ; ++i){ for(int j = 1 ; j <= k ; ++j){ cin >> b[i][j] >> s[i][j]; } } for(int i = 1 ; i <= n ; ++i){ for(int j = 1 ; j <= n ; ++j){ for(int t = 1 ; t <= k ; ++t){ if(s[j][t] != -1 && b[i][t] != -1) profit[i][j] = max(profit[i][j] , s[j][t] - b[i][t]); } } } for(int i = 1 ; i <= n ; ++i){ for(int j = 1 ; j <= n ; ++j){ dis[i][j] = inf; } } for(int i = 1 ; i <= m ; ++i){ int u , v , w;cin >> u >> v >> w; dis[u][v] = min(dis[u][v] , (ll)w); } for(int t = 1 ; t <= n ; ++t){ for(int i = 1 ; i <= n ; ++i){ for(int j = 1 ; j <= n ; ++j){ dis[i][j] = min(dis[i][j] , dis[i][t] + dis[t][j]); } } } int l = 1; int h = 1e9; // for(int i = 1 ; i <= n ; ++i){ // for(int j = 1 ; j <= n ; ++j)cout << dis[i][j] << " \n"[j == n]; // } // for(int i = 1 ; i <= n ; ++i){ // for(int j = 1 ; j <= n ; ++j)cout << profit[i][j] << " \n"[j == n]; // } while(l <= h){ int mid = l + h >> 1; for(int i = 1 ; i <= n ; ++i){ for(int j = 1 ; j <= n ; ++j){ if(1e15 / mid < dis[i][j])dis1[i][j] = 1e13 + 1; else dis1[i][j] = min(inf,dis[i][j] * mid - profit[i][j]); } } for(int t = 1 ; t <= n ; ++t){ for(int i = 1 ; i <= n ; ++i){ for(int j = 1 ; j <= n ; ++j){ dis1[i][j] = min(dis1[i][j] , dis1[i][t] + dis1[t][j]); } } } bool ok = 0; for(int i = 1 ; i <= n ; ++i)ok |= dis1[i][i] <= 0; if(ok == 0)h = mid - 1; else l = mid + 1; } cout << h; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 23 ms | 760 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 504 KB | Output is correct |
2 | Correct | 7 ms | 508 KB | Output is correct |
3 | Correct | 8 ms | 504 KB | Output is correct |
4 | Correct | 7 ms | 504 KB | Output is correct |
5 | Correct | 8 ms | 504 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 7 ms | 504 KB | Output is correct |
8 | Correct | 8 ms | 504 KB | Output is correct |
9 | Correct | 8 ms | 504 KB | Output is correct |
10 | Correct | 8 ms | 504 KB | Output is correct |
11 | Correct | 8 ms | 588 KB | Output is correct |
12 | Correct | 9 ms | 504 KB | Output is correct |
13 | Correct | 8 ms | 504 KB | Output is correct |
14 | Correct | 8 ms | 504 KB | Output is correct |
15 | Correct | 9 ms | 632 KB | Output is correct |
16 | Correct | 8 ms | 760 KB | Output is correct |
17 | Correct | 8 ms | 504 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 9 ms | 632 KB | Output is correct |
20 | Correct | 9 ms | 504 KB | Output is correct |
21 | Correct | 8 ms | 504 KB | Output is correct |
22 | Correct | 8 ms | 508 KB | Output is correct |
23 | Correct | 8 ms | 504 KB | Output is correct |
24 | Correct | 7 ms | 476 KB | Output is correct |
25 | Correct | 8 ms | 504 KB | Output is correct |
26 | Correct | 2 ms | 376 KB | Output is correct |
27 | Correct | 7 ms | 528 KB | Output is correct |
28 | Correct | 7 ms | 632 KB | Output is correct |
29 | Correct | 7 ms | 504 KB | Output is correct |
30 | Correct | 2 ms | 376 KB | Output is correct |
31 | Correct | 8 ms | 504 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 45 ms | 632 KB | Output is correct |
2 | Runtime error | 27 ms | 732 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 504 KB | Output is correct |
2 | Correct | 7 ms | 508 KB | Output is correct |
3 | Correct | 8 ms | 504 KB | Output is correct |
4 | Correct | 7 ms | 504 KB | Output is correct |
5 | Correct | 8 ms | 504 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 7 ms | 504 KB | Output is correct |
8 | Correct | 8 ms | 504 KB | Output is correct |
9 | Correct | 8 ms | 504 KB | Output is correct |
10 | Correct | 8 ms | 504 KB | Output is correct |
11 | Correct | 8 ms | 588 KB | Output is correct |
12 | Correct | 9 ms | 504 KB | Output is correct |
13 | Correct | 8 ms | 504 KB | Output is correct |
14 | Correct | 8 ms | 504 KB | Output is correct |
15 | Correct | 9 ms | 632 KB | Output is correct |
16 | Correct | 8 ms | 760 KB | Output is correct |
17 | Correct | 45 ms | 632 KB | Output is correct |
18 | Runtime error | 27 ms | 732 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
19 | Halted | 0 ms | 0 KB | - |