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>
using namespace std;
#define lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define pll pair<lli,lli>
#define MAX 100
#define MAX_k 1000
//para el vector de hijos
#define des first
#define w second
//para la funcion de solve
#define id second
lli n,m,k,a,b,c,res;
lli camino_op[MAX+2][MAX+2];
lli compra[MAX+2][MAX_k+2], venta[MAX+2][MAX_k+2];//tienda y producto
vector<pll> hijos[MAX+2];
void solve(lli pos) {
priority_queue<pll> cola;
cola.push({0,pos});
rep(i,1,n) camino_op[pos][i] = -1;
pll act;
while (!cola.empty()) {
act = cola.top();
cola.pop();
if (camino_op[pos][act.id] >= 0) continue;
camino_op[pos][act.id] = act.first;
for(auto h : hijos[pos]) {
if(camino_op[pos][h.des] >= 0) continue;
cola.push({act.first+h.w,h.des});
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m >> k;
rep(i,1,n) {
rep(j,1,k*2) {
if(j&1) {
a= (j/2)+1;
cin >> compra[i][a] >> venta[i][a];
}
}
}
rep(i,1,m) {
cin >> a >> b >> c;
hijos[a].push_back({b,c});
}
//camino minimo de todos a todos
rep(i,1,n) solve(i);
//tengo que ver por cada producto que es lo que mas me combiene
res = 0;
rep(prod,1,k){
rep(i,2,n) {
a = compra[1][prod]- venta[i][prod];
b = camino_op[1][i] + camino_op[i][1];
a /= b;
res = max(res,a);
}
}
cout << res;
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... |