# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
108296 | maruii | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 686 ms | 3620 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
#define ff first
#define ss second
priority_queue<pii, vector<pii>, greater<pii> > pq;
int dst[30000];
vector<int> edge[30000];
int main(){
ios_base::sync_with_stdio(0), cin.tie(0);
int N, M, st, ed; cin>>N>>M;
for(int i=0; i<M; ++i){
int b,p; cin>>b>>p;
edge[b].push_back(p);
if(!i) st = b;
else if(i==1) ed = b;
}
fill(dst, dst+N, 1e9);
pq.emplace(0, st); dst[st] = 0;
while(pq.size()){
auto x = pq.top(); pq.pop();
if(x.ff != dst[x.ss]) continue;
for(auto p: edge[x.ss]){
for(int j=0; x.ss+p*j<N; ++j){
if(dst[x.ss+p*j] > x.ff + j){
dst[x.ss+p*j] = x.ff + j;
pq.emplace(x.ff + j, x.ss+p*j);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |