Submission #975539

#TimeUsernameProblemLanguageResultExecution timeMemory
975539edogawa_somethingTravelling Merchant (APIO17_merchant)C++17
0 / 100
13 ms6748 KiB
#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=1001; 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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...