이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define int long long
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
#define ld long double
using namespace std;
typedef pair<int,int> pii;
typedef pair<string, pii> ipii;
const int INF = 1e9+10;
const int MAXN = 110;
const int MAXK = 1010;
const int LOG = 20;
int n, m, k;
int b[MAXN][MAXK], s[MAXN][MAXK];
vector <pii> adj[MAXN][3];
int dis[MAXN][3];
priority_queue <pii> pq;
void dji(int nw, int ty){
for(int i=1; i<=n; i++) dis[i][ty] = INF;
pq.push({0, nw});
dis[nw][ty] = 0;
while(!pq.empty()){
int nw = pq.top().se; int dist = pq.top().fi; pq.pop();
if(dist > dis[nw][ty]) continue;
for(auto ed : adj[nw][ty]){
int wei = ed.se, nx = ed.fi;
if(dis[nx][ty] <= dis[nw][ty] + wei) continue;
dis[nx][ty] = dis[nw][ty] + wei;
pq.push({dis[nx][ty], nx});
}
}
}
signed main(){
cin >> n >> m >> k;
for(int i=1; i<=n; i++){
for(int j=1; j<=k; j++){
cin >> b[i][j] >> s[i][j];
}
}
for(int i=1; i<=m; i++){
int x, y, z; cin >> x >> y >> z;
adj[x][0].pb({y, z});
adj[y][1].pb({x, z});
}
dji(1, 0);
dji(1, 1);
ld ans = 0;
//cout << norm << " p\n";
for(int i=2; i<=n; i++){
int val = 0;
for(int j=1; j<=k; j++){
if(b[1][j] == -1) continue;
int te = s[i][j] - b[1][j];
val = max(val, te);
}
int dist = dis[i][0] + dis[i][1];
ans = max(ans, (ld)val / (ld)dist );
//cout << i << ' ' << dist << ' ' << val << " dist\n";
}
cout << floor(ans) << '\n';
}
# | 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... |