Submission #73383

# Submission time Handle Problem Language Result Execution time Memory
73383 2018-08-28T08:05:26 Z FedericoS Travelling Merchant (APIO17_merchant) C++14
0 / 100
838 ms 1868 KB
#include <iostream>
using namespace std;

int INF=1e9;
int N,M,K;
int x,y;
int C[100][1005][2];
int D[105][105];
int P[105][105];
int DP[55][55][55];

int main(){

	cin>>N>>M>>K;
	for(int i=0;i<N;i++)
		for(int j=0;j<K;j++)
			cin>>C[i][j][0]>>C[i][j][1];

	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			D[i][j]=(i==j)?0:INF;

	for(int i=0;i<M;i++)
		cin>>x>>y>>D[x-1][y-1];

	for(int k=0;k<N;k++)
		for(int i=0;i<N;i++)
			for(int j=0;j<N;j++)
				D[i][j]=min(D[i][j],D[i][k]+D[k][j]);

	for(int a=0;a<N;a++)
		for(int b=0;b<N;b++)
			for(int j=0;j<K;j++)
				if(C[a][j][0]!=-1 and C[b][j][1]!=-1)
					P[a][b]=max(P[a][b],C[b][j][1]-C[a][j][0]);

	for(int k=1;k<N;k++)
		for(int a=0;a<N;a++)
			for(int b=0;b<N;b++)
				DP[a][b][k]=-1;

	for(int a=0;a<N;a++)
		for(int b=0;b<N;b++)
			if(a!=b and D[a][b]==1)
				DP[a][b][1]=P[a][b];

	for(int k=2;k<N;k++)
		for(int a=0;a<N;a++)
			for(int b=0;b<N;b++)
				for(int c=0;c<N;c++)
					if(a!=b and b!=c and a!=c and DP[a][c][k-1]!=-1 and DP[c][b][1]!=-1)
						DP[a][b][k]=max(DP[a][b][k],DP[a][c][k-1]+DP[c][b][1]);
	
	int ans=0;

	for(int a=0;a<N;a++)
		for(int b=0;b<N;b++)
			for(int i=1;i<N;i++)
				for(int j=1;j<N;j++)
					ans=max(ans,(DP[a][b][i]+DP[b][a][j])/(i+j));
/*
	for(int i=1;i<N;i++)
		ans=max(ans,(P[0][i]+P[i][0])/(D[0][i]+D[i][0]));
*/
	cout<<ans;

}
	/*for(int a=0;a<N;a++)
		for(int b=0;b<N;b++)
			cout<<a<<" "<<b<<" "<<P[a][b]<<endl;*/
# Verdict Execution time Memory Grader output
1 Incorrect 838 ms 1868 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 1868 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 726 ms 1868 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 1868 KB Output isn't correct
2 Halted 0 ms 0 KB -