제출 #759289

#제출 시각아이디문제언어결과실행 시간메모리
759289boyliguanhan여행하는 상인 (APIO17_merchant)C++17
21 / 100
413 ms940 KiB
#include<bits/stdc++.h>
#define int long long
#define X(z) x[z][i][j]
#define L F(i,n)F(j,n)
#define F(x,y) for(int x=1;x<=y;++x)
using namespace std;
int n,m,K,x[4][201][201];
bool C(int t) {
    L X(3)=-1e18;
    L {
        if(i==j||X(0)>1e9)continue;
        X(3)=-t*X(0);
        F(k,K) {
            if(x[1][i][k]<0||x[2][j][k]<0)continue;
            X(3)=max(X(3),x[2][j][k]-x[1][i][k]-t*X(0));
        }
    }
    F(k,n)L X(3)=max(X(3),x[3][i][k]+x[3][k][j]);
    F(i,n) if(x[3][i][i]>=0)return 1;
    return 0;
}
signed main() {
    cin >> n >> m >> K;
    L X(0)=2e9;
    F(i,n)F(j,K)cin>>X(1)>>X(2);
    F(k,m){
        int i,j,c;
        cin>>i>>j>>c;
        X(0)=min(X(0),c);
    }
    F(k,n)L X(0)=min(X(0),x[0][i][k]+x[0][k][j]);
    int l=0,r=1e9;
    while(l<r-1){
        if(C(l+r>>1)) l=l+r>>1;
        else r=l+r>>1;
    }
    cout << l<< '\n';
}

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

merchant.cpp: In function 'int main()':
merchant.cpp:34:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   34 |         if(C(l+r>>1)) l=l+r>>1;
      |              ~^~
merchant.cpp:34:26: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   34 |         if(C(l+r>>1)) l=l+r>>1;
      |                         ~^~
merchant.cpp:35:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   35 |         else r=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...