답안 #1075961

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1075961 2024-08-26T10:04:08 Z alexdd Jakarta Skyscrapers (APIO15_skyscraper) C++17
100 / 100
744 ms 3800 KB
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int n,m;
int b[30005],p[30005];
int dist[300005];
priority_queue<pair<int,int>> pq;
vector<int> onpoz[30005];
signed main()
{
    cin>>n>>m;
    for(int i=0;i<n;i++)
        dist[i]=INF;
    for(int i=0;i<m;i++)
    {
        cin>>b[i]>>p[i];
        onpoz[b[i]].push_back(i);
    }
    dist[b[0]]=0;
    pq.push({0,b[0]});
    while(!pq.empty())
    {
        int cdist = -pq.top().first;
        int poz = pq.top().second;
        pq.pop();
        if(dist[poz]!=cdist)
            continue;
        for(int id:onpoz[poz])
        {
            assert(b[id]==poz);
            for(int i=1;poz+i*p[id]<n;i++)
            {
                int cpoz = poz+i*p[id];
                if(dist[cpoz] > dist[poz]+i)
                {
                    dist[cpoz] = dist[poz]+i;
                    pq.push({-dist[cpoz],cpoz});
                }
            }
            for(int i=1;poz-i*p[id]>=0;i++)
            {
                int cpoz = poz-i*p[id];
                if(dist[cpoz] > dist[poz]+i)
                {
                    dist[cpoz] = dist[poz]+i;
                    pq.push({-dist[cpoz],cpoz});
                }
            }
        }
    }
    if(dist[b[1]]==INF)
        cout<<-1;
    else
        cout<<dist[b[1]];
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1368 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 0 ms 1116 KB Output is correct
3 Correct 1 ms 1112 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 0 ms 1116 KB Output is correct
6 Correct 0 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 2 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1112 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 0 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1112 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 1 ms 1112 KB Output is correct
17 Correct 1 ms 1116 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 8 ms 1280 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 2 ms 1116 KB Output is correct
24 Correct 2 ms 1116 KB Output is correct
25 Correct 2 ms 1116 KB Output is correct
26 Correct 4 ms 1116 KB Output is correct
27 Correct 6 ms 1116 KB Output is correct
28 Correct 2 ms 1116 KB Output is correct
29 Correct 2 ms 1116 KB Output is correct
30 Correct 1 ms 1116 KB Output is correct
31 Correct 2 ms 1116 KB Output is correct
32 Correct 2 ms 1116 KB Output is correct
33 Correct 2 ms 1116 KB Output is correct
34 Correct 3 ms 1372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1160 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1140 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1184 KB Output is correct
14 Correct 2 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 1 ms 1116 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 5 ms 1112 KB Output is correct
21 Correct 2 ms 1116 KB Output is correct
22 Correct 2 ms 1116 KB Output is correct
23 Correct 2 ms 1044 KB Output is correct
24 Correct 3 ms 1116 KB Output is correct
25 Correct 2 ms 1168 KB Output is correct
26 Correct 6 ms 1116 KB Output is correct
27 Correct 4 ms 1116 KB Output is correct
28 Correct 2 ms 1116 KB Output is correct
29 Correct 1 ms 1116 KB Output is correct
30 Correct 1 ms 1116 KB Output is correct
31 Correct 1 ms 1116 KB Output is correct
32 Correct 1 ms 1116 KB Output is correct
33 Correct 2 ms 1164 KB Output is correct
34 Correct 2 ms 1372 KB Output is correct
35 Correct 16 ms 1372 KB Output is correct
36 Correct 3 ms 1116 KB Output is correct
37 Correct 13 ms 1372 KB Output is correct
38 Correct 11 ms 1628 KB Output is correct
39 Correct 12 ms 1628 KB Output is correct
40 Correct 16 ms 1628 KB Output is correct
41 Correct 17 ms 1628 KB Output is correct
42 Correct 48 ms 1624 KB Output is correct
43 Correct 49 ms 1624 KB Output is correct
44 Correct 49 ms 1624 KB Output is correct
45 Correct 12 ms 1628 KB Output is correct
46 Correct 16 ms 1616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 2 ms 940 KB Output is correct
3 Correct 1 ms 1368 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 0 ms 1116 KB Output is correct
8 Correct 0 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 2 ms 1192 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 2 ms 1116 KB Output is correct
18 Correct 2 ms 1116 KB Output is correct
19 Correct 1 ms 1112 KB Output is correct
20 Correct 5 ms 1116 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 1 ms 1116 KB Output is correct
24 Correct 3 ms 1116 KB Output is correct
25 Correct 2 ms 1272 KB Output is correct
26 Correct 4 ms 1192 KB Output is correct
27 Correct 5 ms 1116 KB Output is correct
28 Correct 2 ms 1116 KB Output is correct
29 Correct 2 ms 1116 KB Output is correct
30 Correct 1 ms 1116 KB Output is correct
31 Correct 1 ms 1116 KB Output is correct
32 Correct 2 ms 1120 KB Output is correct
33 Correct 3 ms 1320 KB Output is correct
34 Correct 2 ms 1372 KB Output is correct
35 Correct 9 ms 1372 KB Output is correct
36 Correct 2 ms 1116 KB Output is correct
37 Correct 9 ms 1532 KB Output is correct
38 Correct 12 ms 1700 KB Output is correct
39 Correct 13 ms 1556 KB Output is correct
40 Correct 10 ms 1540 KB Output is correct
41 Correct 19 ms 1492 KB Output is correct
42 Correct 88 ms 1628 KB Output is correct
43 Correct 63 ms 1628 KB Output is correct
44 Correct 60 ms 1516 KB Output is correct
45 Correct 15 ms 1712 KB Output is correct
46 Correct 12 ms 1628 KB Output is correct
47 Correct 18 ms 2268 KB Output is correct
48 Correct 17 ms 1792 KB Output is correct
49 Correct 8 ms 1628 KB Output is correct
50 Correct 10 ms 1740 KB Output is correct
51 Correct 30 ms 3028 KB Output is correct
52 Correct 32 ms 2700 KB Output is correct
53 Correct 18 ms 2692 KB Output is correct
54 Correct 2 ms 1372 KB Output is correct
55 Correct 3 ms 1408 KB Output is correct
56 Correct 744 ms 2776 KB Output is correct
57 Correct 34 ms 3540 KB Output is correct
58 Correct 654 ms 1852 KB Output is correct
59 Correct 599 ms 1880 KB Output is correct
60 Correct 715 ms 1624 KB Output is correct
61 Correct 631 ms 1856 KB Output is correct
62 Correct 13 ms 2396 KB Output is correct
63 Correct 23 ms 2776 KB Output is correct
64 Correct 22 ms 2776 KB Output is correct
65 Correct 32 ms 2780 KB Output is correct
66 Correct 37 ms 3800 KB Output is correct
67 Correct 50 ms 3792 KB Output is correct