Submission #320101

#TimeUsernameProblemLanguageResultExecution timeMemory
320101NicolaAbusaad2014Jakarta Skyscrapers (APIO15_skyscraper)C++14
0 / 100
1069 ms364 KiB
/** * Prof.Nicola **/ #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n,m; cin>>n>>m; long long skyscraper[m],jumps[m]; vector<long long>vis(m,-1e9); for(long i=0;i<m;i++){ cin>>skyscraper[i]>>jumps[i]; } priority_queue<pair<long long,pair<long,long> > >pq; pq.push(make_pair(0,make_pair(0,skyscraper[0]))); long long cost,doge,pos,x; while(!pq.empty()){ cost=pq.top().first; doge=pq.top().second.first; pos=pq.top().second.second; vis[doge]=cost; for(long i=0;i<m;i++){ x=abs(skyscraper[i]-pos); if(cost-(x/jumps[doge])>vis[i]&&x%jumps[doge]==0){ pq.push(make_pair(cost-(x/jumps[doge]),make_pair(i,skyscraper[i]))); } } pq.pop(); } if(vis[1]==0){ cout<<-1<<endl; } else{ cout<<-vis[1]<<endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...