답안 #975538

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
975538 2024-05-05T12:42:52 Z edogawa_something 여행하는 상인 (APIO17_merchant) C++17
0 / 100
12 ms 856 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vii;
#define pb push_back
#define S second
#define F first
const ll M=101;
const ll inf=2e18;
ll n,m,k,buy[M][M],sell[M][M],res[M],dis[M];
vector<pair<ll,ll>>adj[M],radj[M];
bool vis[M];
void dij(){
  for(int i=1;i<n;i++)
  dis[i]=inf,res[i]=inf;
  priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>q;
  q.push({0,0});
  while(!q.empty()){
    pair<ll,ll> p=q.top();
    q.pop();
    vis[p.S]=1;
    dis[p.S]=p.F;
    for(auto it:adj[p.S]){
      if(!vis[it.F])
      q.push({it.S+p.F,it.F});
    }
  }
  q.push({0,0});
  for(int i=0;i<n;i++)
  vis[i]=0;
  while(!q.empty()){
    pair<ll,ll> p=q.top();
    q.pop();
    vis[p.S]=1;
    res[p.S]=p.F;
    for(auto it:radj[p.S]){
      if(!vis[it.F])
      q.push({it.S+p.F,it.F});
    }
  }
  for(int i=0;i<n;i++)
  res[i]+=dis[i];
}
int main(){
  ios_base::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++)
    cin>>buy[i][j]>>sell[i][j];
  }
  for(int i=0;i<m;i++){
    ll x,y,z;
    cin>>x>>y>>z;
    x--,y--;
    adj[x].pb({y,z});
    radj[y].pb({x,z});
  }
  dij();
  ll ans=0;
  for(int i=1;i<n;i++){
    for(int j=0;j<k;j++){
      ans=max(ans,(sell[i][j]-buy[0][j])/res[i]);
    }
  }
  cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 12 ms 856 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -