답안 #978099

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
978099 2024-05-08T19:13:48 Z nnin Jakarta Skyscrapers (APIO15_skyscraper) C++17
100 / 100
343 ms 6096 KB
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
 
int N, M, B[30005], P[30005];
int mindis[30005];
set<int> dog[30005];
 
int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>N>>M;
    for(int i=0;i<M;i++) {
        cin>>B[i]>>P[i];
        dog[B[i]].insert(-P[i]);
    }
    for(int i=0;i<N;i++) {
        mindis[i] = 2e9;
    }
    priority_queue<pii, vector<pii>, greater<pii>> pq;
    pq.push({0, B[0]});
    mindis[B[0]] = 0;
    while(!pq.empty()) {
        auto [dis, u] = pq.top();
        pq.pop();
        if(mindis[u]!=dis) continue;
        for(int pp:dog[u]) {
            int p = -pp;
            int v = u+p;
            int w = 1;
            while(v<N) {
                if(mindis[v]>dis+w){
                    mindis[v] = dis+w;
                    pq.push({mindis[v], v});
                }
                v += p;
                w++;
            }
            v = u-p;
            w = 1;
            while(v>=0) {
                if(mindis[v]>dis+w) {
                    mindis[v] = dis+w;
                    pq.push({mindis[v], v});
                }
                v -= p;
                w++;
            }
        }
    }
    if(mindis[B[1]]==2e9) cout<<-1;
    else cout<<mindis[B[1]];
}
 
/*
5 3
0 2
1 1
4 1
*/

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1880 KB Output is correct
2 Correct 1 ms 1884 KB Output is correct
3 Correct 1 ms 1628 KB Output is correct
4 Correct 1 ms 1628 KB Output is correct
5 Correct 1 ms 1628 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 1 ms 1624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1628 KB Output is correct
2 Correct 4 ms 1628 KB Output is correct
3 Correct 1 ms 1628 KB Output is correct
4 Correct 1 ms 1884 KB Output is correct
5 Correct 1 ms 1628 KB Output is correct
6 Correct 1 ms 1884 KB Output is correct
7 Correct 2 ms 1884 KB Output is correct
8 Correct 1 ms 1884 KB Output is correct
9 Correct 1 ms 1884 KB Output is correct
10 Correct 1 ms 1884 KB Output is correct
11 Correct 1 ms 1884 KB Output is correct
12 Correct 1 ms 1880 KB Output is correct
13 Correct 1 ms 1880 KB Output is correct
14 Correct 1 ms 1880 KB Output is correct
15 Correct 1 ms 1880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1628 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Correct 1 ms 1628 KB Output is correct
4 Correct 1 ms 1628 KB Output is correct
5 Correct 1 ms 1628 KB Output is correct
6 Correct 1 ms 1628 KB Output is correct
7 Correct 1 ms 1880 KB Output is correct
8 Correct 1 ms 1884 KB Output is correct
9 Correct 1 ms 1884 KB Output is correct
10 Correct 1 ms 1884 KB Output is correct
11 Correct 1 ms 1884 KB Output is correct
12 Correct 1 ms 1884 KB Output is correct
13 Correct 1 ms 1884 KB Output is correct
14 Correct 1 ms 1884 KB Output is correct
15 Correct 1 ms 1884 KB Output is correct
16 Correct 1 ms 1884 KB Output is correct
17 Correct 1 ms 1880 KB Output is correct
18 Correct 1 ms 1884 KB Output is correct
19 Correct 1 ms 1712 KB Output is correct
20 Correct 5 ms 1884 KB Output is correct
21 Correct 1 ms 1884 KB Output is correct
22 Correct 1 ms 1884 KB Output is correct
23 Correct 1 ms 1884 KB Output is correct
24 Correct 2 ms 1884 KB Output is correct
25 Correct 2 ms 1880 KB Output is correct
26 Correct 1 ms 1884 KB Output is correct
27 Correct 1 ms 1888 KB Output is correct
28 Correct 1 ms 1884 KB Output is correct
29 Correct 2 ms 1880 KB Output is correct
30 Correct 2 ms 1884 KB Output is correct
31 Correct 1 ms 1884 KB Output is correct
32 Correct 1 ms 1884 KB Output is correct
33 Correct 2 ms 2140 KB Output is correct
34 Correct 2 ms 1884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1628 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Correct 1 ms 1628 KB Output is correct
4 Correct 1 ms 1628 KB Output is correct
5 Correct 1 ms 1628 KB Output is correct
6 Correct 1 ms 1884 KB Output is correct
7 Correct 1 ms 1884 KB Output is correct
8 Correct 1 ms 1884 KB Output is correct
9 Correct 1 ms 1884 KB Output is correct
10 Correct 1 ms 1880 KB Output is correct
11 Correct 1 ms 1884 KB Output is correct
12 Correct 1 ms 1884 KB Output is correct
13 Correct 1 ms 1880 KB Output is correct
14 Correct 1 ms 1884 KB Output is correct
15 Correct 1 ms 1884 KB Output is correct
16 Correct 1 ms 1884 KB Output is correct
17 Correct 1 ms 1884 KB Output is correct
18 Correct 2 ms 1876 KB Output is correct
19 Correct 1 ms 1884 KB Output is correct
20 Correct 3 ms 1884 KB Output is correct
21 Correct 1 ms 1884 KB Output is correct
22 Correct 1 ms 1884 KB Output is correct
23 Correct 1 ms 1884 KB Output is correct
24 Correct 2 ms 1884 KB Output is correct
25 Correct 3 ms 1884 KB Output is correct
26 Correct 2 ms 1884 KB Output is correct
27 Correct 2 ms 1884 KB Output is correct
28 Correct 1 ms 1884 KB Output is correct
29 Correct 2 ms 1884 KB Output is correct
30 Correct 1 ms 1884 KB Output is correct
31 Correct 2 ms 1884 KB Output is correct
32 Correct 1 ms 1880 KB Output is correct
33 Correct 2 ms 1884 KB Output is correct
34 Correct 2 ms 1884 KB Output is correct
35 Correct 8 ms 3420 KB Output is correct
36 Correct 2 ms 2136 KB Output is correct
37 Correct 6 ms 3164 KB Output is correct
38 Correct 9 ms 3676 KB Output is correct
39 Correct 9 ms 3676 KB Output is correct
40 Correct 10 ms 3676 KB Output is correct
41 Correct 9 ms 3696 KB Output is correct
42 Correct 4 ms 2140 KB Output is correct
43 Correct 4 ms 2140 KB Output is correct
44 Correct 6 ms 2392 KB Output is correct
45 Correct 10 ms 3672 KB Output is correct
46 Correct 10 ms 3676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1628 KB Output is correct
2 Correct 1 ms 1624 KB Output is correct
3 Correct 1 ms 1628 KB Output is correct
4 Correct 1 ms 1884 KB Output is correct
5 Correct 1 ms 1628 KB Output is correct
6 Correct 1 ms 1884 KB Output is correct
7 Correct 1 ms 1628 KB Output is correct
8 Correct 1 ms 1880 KB Output is correct
9 Correct 1 ms 1884 KB Output is correct
10 Correct 1 ms 1884 KB Output is correct
11 Correct 1 ms 1884 KB Output is correct
12 Correct 2 ms 1872 KB Output is correct
13 Correct 1 ms 1884 KB Output is correct
14 Correct 2 ms 1884 KB Output is correct
15 Correct 1 ms 1884 KB Output is correct
16 Correct 1 ms 1884 KB Output is correct
17 Correct 1 ms 1884 KB Output is correct
18 Correct 1 ms 1884 KB Output is correct
19 Correct 1 ms 1884 KB Output is correct
20 Correct 3 ms 2048 KB Output is correct
21 Correct 1 ms 1888 KB Output is correct
22 Correct 1 ms 1884 KB Output is correct
23 Correct 1 ms 2132 KB Output is correct
24 Correct 2 ms 1884 KB Output is correct
25 Correct 2 ms 1884 KB Output is correct
26 Correct 1 ms 1880 KB Output is correct
27 Correct 1 ms 1880 KB Output is correct
28 Correct 1 ms 1884 KB Output is correct
29 Correct 2 ms 2060 KB Output is correct
30 Correct 1 ms 1884 KB Output is correct
31 Correct 1 ms 1884 KB Output is correct
32 Correct 1 ms 1880 KB Output is correct
33 Correct 2 ms 1948 KB Output is correct
34 Correct 2 ms 2132 KB Output is correct
35 Correct 8 ms 3420 KB Output is correct
36 Correct 2 ms 2140 KB Output is correct
37 Correct 6 ms 3164 KB Output is correct
38 Correct 10 ms 3676 KB Output is correct
39 Correct 12 ms 3844 KB Output is correct
40 Correct 10 ms 3672 KB Output is correct
41 Correct 10 ms 3676 KB Output is correct
42 Correct 4 ms 2296 KB Output is correct
43 Correct 4 ms 2140 KB Output is correct
44 Correct 6 ms 2396 KB Output is correct
45 Correct 10 ms 3676 KB Output is correct
46 Correct 10 ms 3676 KB Output is correct
47 Correct 14 ms 4056 KB Output is correct
48 Correct 6 ms 3420 KB Output is correct
49 Correct 5 ms 3348 KB Output is correct
50 Correct 4 ms 2908 KB Output is correct
51 Correct 20 ms 5076 KB Output is correct
52 Correct 22 ms 4568 KB Output is correct
53 Correct 12 ms 4568 KB Output is correct
54 Correct 2 ms 2140 KB Output is correct
55 Correct 3 ms 2140 KB Output is correct
56 Correct 343 ms 4188 KB Output is correct
57 Correct 35 ms 4304 KB Output is correct
58 Correct 6 ms 2392 KB Output is correct
59 Correct 6 ms 2492 KB Output is correct
60 Correct 6 ms 2472 KB Output is correct
61 Correct 7 ms 2652 KB Output is correct
62 Correct 7 ms 3932 KB Output is correct
63 Correct 28 ms 5072 KB Output is correct
64 Correct 27 ms 4820 KB Output is correct
65 Correct 30 ms 5840 KB Output is correct
66 Correct 41 ms 6096 KB Output is correct
67 Correct 37 ms 5836 KB Output is correct