제출 #203000

#제출 시각아이디문제언어결과실행 시간메모리
203000AQT여행하는 상인 (APIO17_merchant)C++14
100 / 100
151 ms6648 KiB
#include <bits/stdc++.h> using namespace std; int N, M, K; long long mx[1005][1005]; long long dis[1005][1005]; long long buy[1005][10005]; long long sell[1005][10005]; long long tmp[1005][1005]; long long a, b, c; bool solve(long long k){ for(int i =1 ; i<=N; i++){ for(int j = 1; j<=M; j++){ tmp[i][j] = mx[i][j] - k*dis[i][j]; } } for(int k = 1; k<=N; k++){ for(int i = 1; i<=N; i++){ for(int j = 1; j<=N; j++){ if(i == j){ if(k != i && tmp[i][k] + tmp[k][j] >= 0){ return 1; } } tmp[i][j] = max(tmp[i][j], tmp[i][k] + tmp[k][j]); } } } return 0; } int main(){ cin.sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> M >> K; for(int i =1 ; i<=N; i++){ for(int k = 1; k<=K; k++){ cin >> buy[i][k] >> sell[i][k]; } } for(int i = 1; i<=N; i++){ for(int j = 1; j<=N; j++){ for(int k = 1; k<=K; k++){ if(sell[j][k]+1 && buy[i][k]+1){ mx[i][j] = max(mx[i][j], sell[j][k] - buy[i][k]); } } } } for(int i = 1; i<=N; i++){ for(int j = 1; j<=N; j++){ dis[i][j] = 2000000000; if(i == j){ dis[i][j] = 0; } } } for(int i = 1; i<=M; i++){ cin >> a >> b >> c; dis[a][b] = min(dis[a][b], c); } for(int k = 1; k<=N; k++){ for(int i = 1; i<=N; i++){ for(int j = 1; j<=N; j++){ dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]); } } } int l = 1,r = 1000000000, ans = 0; while(l <= r){ int mid = l + r>> 1; if(solve(mid)){ l = mid + 1; ans = mid; } else{ r =mid - 1; } } cout << ans << endl; }

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

merchant.cpp: In function 'int main()':
merchant.cpp:74:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int mid = l + r>> 1;
             ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...