Submission #134993

# Submission time Handle Problem Language Result Execution time Memory
134993 2019-07-23T13:52:32 Z wzy Travelling Merchant (APIO17_merchant) C++11
0 / 100
32 ms 3836 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
const int K = 1005;
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
int n , m , k;
ll b[N][K] , s[N][K];
ll dist[N][N];
int32_t main(){
	scanf("%d%d%d" , &n , &m , &k);
	for(int i = 0 ; i < n; i++){
		for(int j = 0 ; j < k ; j++){
			scanf("%lld%lld" , &b[i][j], & s[i][j]);
			if(b[i][j] == -1){
				b[i][j] = (ll) 1e9 + (ll) 1e9;
			}
			if(s[i][j] == -1){
				s[i][j] = - (ll) 1e9 - (ll) 1e9;
			}
		}
	}
	for(int i = 0 ; i < N ; i ++){
		for(int j = 0 ; j < N ; j ++ ){
			dist[i][j] = (ll) 1e15;
		}
		dist[i][i] = 0;
	}
	for(int i = 0 ; i < m ; i ++){
		int  u , v, x;
		scanf("%d%d%d" , &u , & v  , &x);
		u-- , v--;
		dist[u][v] = min(dist[u][v] , (ll) x);
	}
	for(int i = 0 ; i < n; i ++ ){
		for(int j = 0 ; j < n ; j ++){
			for(int k = 0 ; k < n ; k ++){
				dist[j][k] = min(dist[j][i] + dist[i][k] , dist[j][k]);
			}
		}
	}
	long long int ans = 0;
	for(int i = 0 ; i < n; i ++){
		for(int j = 0 ; j < n ; j ++){
			long long int U = dist[i][j] + dist[j][i];
			for(int x = 0 ; x < k ; x++){
				long long int C = -b[i][x] + s[j][x];
				ans = max(ans , C/U);
			}
		}
	}
	cout<<ans<<endl;
}

Compilation message

merchant.cpp: In function 'int32_t main()':
merchant.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d" , &n , &m , &k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:18:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%lld%lld" , &b[i][j], & s[i][j]);
    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d" , &u , & v  , &x);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 32 ms 3836 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1532 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 2552 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1532 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -