답안 #111447

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
111447 2019-05-15T11:42:15 Z Segtree 여행하는 상인 (APIO17_merchant) C++14
0 / 100
64 ms 5112 KB
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
#define N 110
#define K 1010
ll n,m,k,d[N][N];
ll s[N][K],b[N][K];
void wf(){
    for(int r=1;r<=n;r++){
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++){
	    d[i][j]=min(d[i][j],d[i][r]+d[r][j]);
	}
    }
}
int main(){
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)d[i][j]=1e17;
    for(int i=1;i<=n;i++){
	for(int j=0;j<k;j++)cin>>s[i][j]>>b[i][j];
	d[i][i]=0;
    } 
    for(int i=0;i<m;i++){
	ll x,y,z;cin>>x>>y>>z;
	d[x][y]=z;
    }
    wf();
    ll ans=0;
    for(int i=1;i<=n;i++){
	ll len=d[1][i]+d[i][1];
	ll ma=0;
	for(int j=0;j<k;j++){
	    if(b[1][j]==-1)continue;
	    ma=max(ma,s[i][j]-b[1][j]);
	}
	ans=max(ans,ma/len);
    }
    cout<<ans<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 64 ms 5112 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 1408 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 13 ms 2660 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 1408 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -