# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
73647 | 2018-08-28T16:15:39 Z | Vardanyan | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 4 ms | 1268 KB |
//#pragma GCC optimize "-O3" #include <bits/stdc++.h> using namespace std; const int N = 30007; vector<pair<int,int> > g[N]; int B[N],P[N]; int dist[N]; int main() { int n,m; scanf("%d%d",&n,&m); for(int i = 0;i<m;i++){ int b,p; scanf("%d%d",&b,&p); int bb = b; int c = 1; while(bb+p<n){ bb+=p; g[b].push_back({bb,c}); c++; } bb = b; c = 1; while(bb-p>=0){ bb-=p; g[b].push_back({bb,c}); c++; } } priority_queue<pair<int,int> > pq; dist[0] = 0; for(int i = 1;i<=n;i++) dist[i] = 1000*1000*1000+7; pq.push({0,0}); while(!pq.empty()){ pair<int,int> v = pq.top(); pq.pop(); int gag = v.second; for(int i = 0;i<g[gag].size();i++){ int to = g[gag][i].first; int d = g[gag][i].second; if(d+(-v.first)<dist[to]){ dist[to] = d+(-v.first); pq.push({-dist[to],to}); } } } if(dist[1] == 1000*1000*1000+7) dist[1] = -1; cout<<dist[1]<<endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1016 KB | Output is correct |
2 | Incorrect | 3 ms | 1256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1256 KB | Output is correct |
2 | Incorrect | 3 ms | 1268 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1268 KB | Output is correct |
2 | Incorrect | 3 ms | 1268 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1268 KB | Output is correct |
2 | Incorrect | 3 ms | 1268 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1268 KB | Output is correct |
2 | Incorrect | 3 ms | 1268 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |