답안 #42129

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
42129 2018-02-22T18:29:53 Z XmtosX Jakarta Skyscrapers (APIO15_skyscraper) C++14
36 / 100
1000 ms 3096 KB
#include <bits/stdc++.h>
using namespace std;
int n,p[30004],b[30004],m;
priority_queue <pair<int,int> ,vector <pair<int,int> >,greater <pair<int,int> > > pq;
bool vis[30004];
vector <int> v[30004];
int cur[30004];
void dij()
{
    for (int i=1;i<m;i++)
        cur[i]=INT_MAX;
    pq.push({0,0});
    while (!pq.empty())
    {
        int x= (pq.top()).second;
        int y= (pq.top()).first;
        pq.pop();
        if (vis[x])
            continue;
        vis[x]=true;
        for (int i=0;i*p[x]+b[x]<n;i++)
        {
            int a= (i*p[x]+b[x]);
            for (int j=0;j<v[a].size();j++)
            {
                if (!vis[v[a][j]]&&cur[v[a][j]]>i+y)
                {
                    pq.push({i+y,v[a][j]});
                    cur[v[a][j]]=i+y;
                }
            }
        }
        for (int i=1;b[x]-i*p[x]>=0;i++)
        {
            int a= (b[x]-i*p[x]);
            for (int j=0;j<v[a].size();j++)
            {
                if (!vis[v[a][j]]&&cur[v[a][j]]>i+y)
                {
                    pq.push({i+y,v[a][j]});
                    cur[v[a][j]]=i+y;
                }
            }
        }
    }
}
int main()
{
    cin >>n>>m;
    for (int i=0;i<m;i++)
    {
        cin >>b[i]>>p[i];
        v[b[i]].push_back(i);
    }
    dij();
    if (!vis[1])
        cout <<-1;
    else
        cout <<cur[1];
    return 0;
}

Compilation message

skyscraper.cpp: In function 'void dij()':
skyscraper.cpp:24:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int j=0;j<v[a].size();j++)
                           ^
skyscraper.cpp:36:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int j=0;j<v[a].size();j++)
                           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1016 KB Output is correct
2 Correct 2 ms 1120 KB Output is correct
3 Correct 2 ms 1120 KB Output is correct
4 Correct 2 ms 1120 KB Output is correct
5 Correct 2 ms 1136 KB Output is correct
6 Correct 2 ms 1140 KB Output is correct
7 Correct 2 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1208 KB Output is correct
2 Correct 2 ms 1336 KB Output is correct
3 Correct 2 ms 1336 KB Output is correct
4 Correct 2 ms 1336 KB Output is correct
5 Correct 2 ms 1336 KB Output is correct
6 Correct 2 ms 1336 KB Output is correct
7 Correct 2 ms 1336 KB Output is correct
8 Correct 2 ms 1336 KB Output is correct
9 Correct 2 ms 1336 KB Output is correct
10 Correct 2 ms 1336 KB Output is correct
11 Correct 4 ms 1392 KB Output is correct
12 Correct 9 ms 1392 KB Output is correct
13 Correct 9 ms 1392 KB Output is correct
14 Correct 4 ms 1392 KB Output is correct
15 Correct 4 ms 1392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1392 KB Output is correct
2 Correct 2 ms 1392 KB Output is correct
3 Correct 2 ms 1392 KB Output is correct
4 Correct 2 ms 1392 KB Output is correct
5 Correct 2 ms 1392 KB Output is correct
6 Correct 2 ms 1392 KB Output is correct
7 Correct 2 ms 1392 KB Output is correct
8 Correct 2 ms 1392 KB Output is correct
9 Correct 2 ms 1392 KB Output is correct
10 Correct 2 ms 1392 KB Output is correct
11 Correct 5 ms 1420 KB Output is correct
12 Correct 9 ms 1420 KB Output is correct
13 Correct 9 ms 1420 KB Output is correct
14 Correct 4 ms 1420 KB Output is correct
15 Correct 4 ms 1516 KB Output is correct
16 Correct 2 ms 1516 KB Output is correct
17 Correct 4 ms 1516 KB Output is correct
18 Correct 2 ms 1516 KB Output is correct
19 Correct 2 ms 1516 KB Output is correct
20 Correct 25 ms 1516 KB Output is correct
21 Correct 2 ms 1516 KB Output is correct
22 Correct 2 ms 1516 KB Output is correct
23 Correct 3 ms 1516 KB Output is correct
24 Correct 4 ms 1516 KB Output is correct
25 Correct 4 ms 1516 KB Output is correct
26 Correct 21 ms 1516 KB Output is correct
27 Correct 20 ms 1516 KB Output is correct
28 Correct 3 ms 1516 KB Output is correct
29 Correct 3 ms 1516 KB Output is correct
30 Correct 2 ms 1516 KB Output is correct
31 Correct 2 ms 1516 KB Output is correct
32 Correct 2 ms 1516 KB Output is correct
33 Correct 4 ms 1516 KB Output is correct
34 Correct 5 ms 1516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1516 KB Output is correct
2 Correct 2 ms 1516 KB Output is correct
3 Correct 2 ms 1516 KB Output is correct
4 Correct 2 ms 1516 KB Output is correct
5 Correct 2 ms 1516 KB Output is correct
6 Correct 2 ms 1516 KB Output is correct
7 Correct 2 ms 1516 KB Output is correct
8 Correct 2 ms 1516 KB Output is correct
9 Correct 2 ms 1516 KB Output is correct
10 Correct 2 ms 1516 KB Output is correct
11 Correct 4 ms 1516 KB Output is correct
12 Correct 9 ms 1516 KB Output is correct
13 Correct 11 ms 1516 KB Output is correct
14 Correct 4 ms 1516 KB Output is correct
15 Correct 4 ms 1516 KB Output is correct
16 Correct 2 ms 1516 KB Output is correct
17 Correct 4 ms 1516 KB Output is correct
18 Correct 2 ms 1516 KB Output is correct
19 Correct 2 ms 1516 KB Output is correct
20 Correct 25 ms 1516 KB Output is correct
21 Correct 2 ms 1516 KB Output is correct
22 Correct 2 ms 1516 KB Output is correct
23 Correct 3 ms 1516 KB Output is correct
24 Correct 4 ms 1516 KB Output is correct
25 Correct 4 ms 1516 KB Output is correct
26 Correct 22 ms 1516 KB Output is correct
27 Correct 20 ms 1516 KB Output is correct
28 Correct 3 ms 1516 KB Output is correct
29 Correct 3 ms 1516 KB Output is correct
30 Correct 3 ms 1516 KB Output is correct
31 Correct 3 ms 1516 KB Output is correct
32 Correct 2 ms 1516 KB Output is correct
33 Correct 4 ms 1516 KB Output is correct
34 Correct 5 ms 1516 KB Output is correct
35 Correct 45 ms 2412 KB Output is correct
36 Correct 7 ms 2412 KB Output is correct
37 Correct 42 ms 2412 KB Output is correct
38 Correct 58 ms 3048 KB Output is correct
39 Correct 61 ms 3096 KB Output is correct
40 Correct 61 ms 3096 KB Output is correct
41 Correct 57 ms 3096 KB Output is correct
42 Execution timed out 1064 ms 3096 KB Time limit exceeded
43 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3096 KB Output is correct
2 Correct 2 ms 3096 KB Output is correct
3 Correct 3 ms 3096 KB Output is correct
4 Correct 2 ms 3096 KB Output is correct
5 Correct 2 ms 3096 KB Output is correct
6 Correct 2 ms 3096 KB Output is correct
7 Correct 2 ms 3096 KB Output is correct
8 Correct 2 ms 3096 KB Output is correct
9 Correct 2 ms 3096 KB Output is correct
10 Correct 3 ms 3096 KB Output is correct
11 Correct 5 ms 3096 KB Output is correct
12 Correct 10 ms 3096 KB Output is correct
13 Correct 11 ms 3096 KB Output is correct
14 Correct 6 ms 3096 KB Output is correct
15 Correct 4 ms 3096 KB Output is correct
16 Correct 3 ms 3096 KB Output is correct
17 Correct 5 ms 3096 KB Output is correct
18 Correct 3 ms 3096 KB Output is correct
19 Correct 3 ms 3096 KB Output is correct
20 Correct 28 ms 3096 KB Output is correct
21 Correct 3 ms 3096 KB Output is correct
22 Correct 3 ms 3096 KB Output is correct
23 Correct 3 ms 3096 KB Output is correct
24 Correct 4 ms 3096 KB Output is correct
25 Correct 4 ms 3096 KB Output is correct
26 Correct 30 ms 3096 KB Output is correct
27 Correct 20 ms 3096 KB Output is correct
28 Correct 4 ms 3096 KB Output is correct
29 Correct 3 ms 3096 KB Output is correct
30 Correct 2 ms 3096 KB Output is correct
31 Correct 3 ms 3096 KB Output is correct
32 Correct 2 ms 3096 KB Output is correct
33 Correct 5 ms 3096 KB Output is correct
34 Correct 6 ms 3096 KB Output is correct
35 Correct 47 ms 3096 KB Output is correct
36 Correct 8 ms 3096 KB Output is correct
37 Correct 45 ms 3096 KB Output is correct
38 Correct 63 ms 3096 KB Output is correct
39 Correct 59 ms 3096 KB Output is correct
40 Correct 61 ms 3096 KB Output is correct
41 Correct 60 ms 3096 KB Output is correct
42 Execution timed out 1056 ms 3096 KB Time limit exceeded
43 Halted 0 ms 0 KB -