# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
252912 | Badrangiikh | Travelling Merchant (APIO17_merchant) | C++14 | 25 ms | 1400 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include <deque>
#include <cmath>
using namespace std;
#define ll long long
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
long long n , m , k , i , maxx , minn , x , y , j , z , sz , l ;
map < pair < long long , long long > , long long > mp ;
long long path [ 145 ] [ 145 ] ;
int main() {
scanf ( "%lld%lld%lld" , & n , & m , & k ) ;
maxx = 0 ;
for ( i = 1 ; i <= n ; i ++ ) {
for ( j = 1 ; j <= k ; j ++ ) {
scanf ( "%lld%lld" , & x , & y ) ;
if ( i == 1 && x > 0 && y > 0 ) {
maxx = max ( maxx , y - x ) ;
}
}
}
for ( i = 1 ; i <= n ; i ++ ) {
for ( j = 1 ; j <= n ; j ++ ) {
path [ i ] [ j ] = 1234567890 ;
if ( i == j ) path [ i ] [ j ] = 0 ;
}
}
for ( i = 1 ; i <= m ; i ++ ) {
scanf ( "%lld%lld%lld" , & x , & y , & z ) ;
path [ x ] [ y ] = z ;
}
for ( i = 1 ; i <= n ; i ++ ) {
for ( j = 1 ; j <= n ; j ++ ) {
for ( l = 1 ; l <= n ; l ++ ) {
path [ j ] [ l ] = min ( path [ j ] [ l ] , path [ j ] [ i ] + path [ i ] [ l ] ) ;
}
}
}
minn = 1234567890 ;
for ( i = 2 ; i <= n ; i ++ ) {
minn = min ( minn , path [ 1 ] [ i ] + path [ i ] [ 1 ] ) ;
}
printf ( "%lld" , maxx / minn ) ;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |