Submission #903902

#TimeUsernameProblemLanguageResultExecution timeMemory
903902irmuunTravelling Merchant (APIO17_merchant)C++17
12 / 100
17 ms3152 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n,m,k; cin>>n>>m>>k; ll b[n][k],s[n][k]; for(ll i=0;i<n;i++){ for(ll j=0;j<k;j++){ cin>>b[i][j]>>s[i][j]; } } vector<pair<ll,ll>>adj[n]; for(ll i=0;i<m;i++){ ll u,v,t; cin>>u>>v>>t; u--,v--; adj[u].pb({v,t}); } ll dist[n][n]; for(ll i=0;i<n;i++){ for(ll j=0;j<n;j++){ dist[i][j]=1e18; } } for(ll i=0;i<n;i++){ set<pair<ll,ll>>st; st.insert({0,i}); dist[i][i]=0; while(!st.empty()){ auto [t,x]=*st.begin(); st.erase(st.begin()); for(auto [j,d]:adj[x]){ if(t+d<dist[i][j]){ if(dist[i][j]<1e18){ st.erase({dist[i][j],j}); } dist[i][j]=t+d; st.insert({dist[i][j],j}); } } } } ll ans=0; for(ll i=1;i<n;i++){//i -> 0 -> i if(dist[0][i]==1e18||dist[i][0]==1e18){ continue; } ll mx=0; for(ll j=0;j<k;j++){ if(b[0][j]>-1&&s[i][j]>-1){ mx=max(mx,s[i][j]-b[0][j]); } } ans=max(ans,mx/(dist[i][0]+dist[0][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...