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 <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<ll, ll>
#define f first
#define s second
pi operator+(pi x, pi y){
return {x.f + y.f, x.s + y.s};
}
const int inf = 0x3f3f3f3f;
const int mxn = 100, mxk = 1000;
int n, m, k;
ll a[mxn][mxk][2];
pi g[mxn][mxn], g2[mxn][mxn];
ll f(pi p){
return p.f / p.s;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m >> k;
for(int i = 0; i < n; i++)
for(int j = 0; j < k; j++)
for(int l = 0; l < 2; l++){
cin >> a[i][j][l];
}
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++){
g[i][j] = {0, inf};
for(int l = 0; l < k; l++){
if(~a[i][l][0] && ~a[j][l][1]) g[i][j].f = max(g[i][j].f, a[j][l][1] - a[i][l][0]);
}
}
for(int i = 0; i < m; i++){
ll u, v, w;
cin >> u >> v >> w;
u--, v--;
g[u][v].s = min(g[u][v].s, w);
}
for(int l = 0; l < n; l++)
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++){
g[i][j].s = min(g[i][j].s, g[i][l].s + g[l][j].s);
}
/*
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++){
cout << g[i][j].f << " " << g[i][j].s << " | ";
if(j == n - 1) cout << endl;
}
cout << endl;
*/
ll ret = 0;
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++){
if(g[0][i].s != inf && g[i][0].s != inf){
ret = max(ret, f(g[i][j] + g[j][i]));
}
}
cout << ret << endl;
return 0;
}
# | 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... |