답안 #42127

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
42127 2018-02-22T18:24:13 Z XmtosX Jakarta Skyscrapers (APIO15_skyscraper) C++14
36 / 100
1000 ms 5528 KB
#include <bits/stdc++.h>
using namespace std;
long long n,p[30004],b[30004],m;
priority_queue <pair<long long,long long> ,vector <pair<long long,long long> >,greater <pair<long long,long long> > > pq;
bool vis[30004];
vector <long long> v[30004];
long long cur[30004];
void dij()
{
    for (int i=0;i<m;i++)
        cur[i]=LONG_LONG_MAX;
    for (int i=0;i<v[b[0]].size();i++)
        cur[v[b[0]][i]]=0,pq.push({0,v[b[0]][i]});
    while (!pq.empty())
    {
        long long x= (pq.top()).second;
        long long y= (pq.top()).first;
        pq.pop();
        if (vis[x])
            continue;
        vis[x]=true;
        for (long long i=0;i*p[x]+b[x]<n;i++)
        {
            long long a= (i*p[x]+b[x]);
            for (int j=0;j<v[a].size();j++)
            {
                if (cur[v[a][j]]>i+y)
                {
                    pq.push({i+y,v[a][j]});
                    cur[v[a][j]]=i+y;
                }
            }
        }
        for (long long i=0;b[x]-i*p[x]>=0;i++)
        {
            long long a= (b[x]-i*p[x]);
            for (int j=0;j<v[a].size();j++)
            {
                if (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:12:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<v[b[0]].size();i++)
                   ^
skyscraper.cpp:25:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int j=0;j<v[a].size();j++)
                           ^
skyscraper.cpp:37: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 1228 KB Output is correct
6 Correct 2 ms 1228 KB Output is correct
7 Correct 2 ms 1228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1228 KB Output is correct
2 Correct 2 ms 1300 KB Output is correct
3 Correct 2 ms 1300 KB Output is correct
4 Correct 2 ms 1300 KB Output is correct
5 Correct 2 ms 1300 KB Output is correct
6 Correct 2 ms 1300 KB Output is correct
7 Correct 2 ms 1300 KB Output is correct
8 Correct 2 ms 1300 KB Output is correct
9 Correct 2 ms 1300 KB Output is correct
10 Correct 2 ms 1300 KB Output is correct
11 Correct 4 ms 1516 KB Output is correct
12 Correct 18 ms 1516 KB Output is correct
13 Correct 14 ms 1516 KB Output is correct
14 Correct 4 ms 1552 KB Output is correct
15 Correct 4 ms 1564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1564 KB Output is correct
2 Correct 2 ms 1564 KB Output is correct
3 Correct 2 ms 1564 KB Output is correct
4 Correct 2 ms 1564 KB Output is correct
5 Correct 2 ms 1564 KB Output is correct
6 Correct 2 ms 1564 KB Output is correct
7 Correct 2 ms 1564 KB Output is correct
8 Correct 2 ms 1564 KB Output is correct
9 Correct 2 ms 1564 KB Output is correct
10 Correct 2 ms 1564 KB Output is correct
11 Correct 5 ms 1576 KB Output is correct
12 Correct 19 ms 1576 KB Output is correct
13 Correct 17 ms 1576 KB Output is correct
14 Correct 4 ms 1612 KB Output is correct
15 Correct 5 ms 1624 KB Output is correct
16 Correct 2 ms 1624 KB Output is correct
17 Correct 4 ms 1644 KB Output is correct
18 Correct 3 ms 1644 KB Output is correct
19 Correct 2 ms 1644 KB Output is correct
20 Correct 27 ms 1680 KB Output is correct
21 Correct 3 ms 1680 KB Output is correct
22 Correct 3 ms 1704 KB Output is correct
23 Correct 3 ms 1704 KB Output is correct
24 Correct 4 ms 1704 KB Output is correct
25 Correct 4 ms 1748 KB Output is correct
26 Correct 24 ms 1748 KB Output is correct
27 Correct 27 ms 1748 KB Output is correct
28 Correct 3 ms 1748 KB Output is correct
29 Correct 3 ms 1748 KB Output is correct
30 Correct 2 ms 1748 KB Output is correct
31 Correct 2 ms 1748 KB Output is correct
32 Correct 2 ms 1748 KB Output is correct
33 Correct 5 ms 1844 KB Output is correct
34 Correct 5 ms 1880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1880 KB Output is correct
2 Correct 2 ms 1880 KB Output is correct
3 Correct 2 ms 1880 KB Output is correct
4 Correct 2 ms 1880 KB Output is correct
5 Correct 2 ms 1880 KB Output is correct
6 Correct 2 ms 1880 KB Output is correct
7 Correct 2 ms 1880 KB Output is correct
8 Correct 2 ms 1880 KB Output is correct
9 Correct 2 ms 1880 KB Output is correct
10 Correct 2 ms 1880 KB Output is correct
11 Correct 4 ms 1880 KB Output is correct
12 Correct 16 ms 1880 KB Output is correct
13 Correct 13 ms 1880 KB Output is correct
14 Correct 4 ms 2032 KB Output is correct
15 Correct 4 ms 2036 KB Output is correct
16 Correct 2 ms 2036 KB Output is correct
17 Correct 5 ms 2036 KB Output is correct
18 Correct 2 ms 2036 KB Output is correct
19 Correct 2 ms 2036 KB Output is correct
20 Correct 25 ms 2036 KB Output is correct
21 Correct 4 ms 2036 KB Output is correct
22 Correct 2 ms 2036 KB Output is correct
23 Correct 3 ms 2036 KB Output is correct
24 Correct 4 ms 2036 KB Output is correct
25 Correct 4 ms 2036 KB Output is correct
26 Correct 25 ms 2036 KB Output is correct
27 Correct 26 ms 2068 KB Output is correct
28 Correct 4 ms 2068 KB Output is correct
29 Correct 3 ms 2068 KB Output is correct
30 Correct 2 ms 2068 KB Output is correct
31 Correct 2 ms 2068 KB Output is correct
32 Correct 3 ms 2068 KB Output is correct
33 Correct 4 ms 2088 KB Output is correct
34 Correct 5 ms 2228 KB Output is correct
35 Correct 45 ms 4284 KB Output is correct
36 Correct 7 ms 4284 KB Output is correct
37 Correct 41 ms 4284 KB Output is correct
38 Correct 61 ms 5396 KB Output is correct
39 Correct 58 ms 5396 KB Output is correct
40 Correct 63 ms 5528 KB Output is correct
41 Correct 59 ms 5528 KB Output is correct
42 Execution timed out 1071 ms 5528 KB Time limit exceeded
43 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5528 KB Output is correct
2 Correct 2 ms 5528 KB Output is correct
3 Correct 2 ms 5528 KB Output is correct
4 Correct 2 ms 5528 KB Output is correct
5 Correct 2 ms 5528 KB Output is correct
6 Correct 2 ms 5528 KB Output is correct
7 Correct 2 ms 5528 KB Output is correct
8 Correct 2 ms 5528 KB Output is correct
9 Correct 2 ms 5528 KB Output is correct
10 Correct 2 ms 5528 KB Output is correct
11 Correct 4 ms 5528 KB Output is correct
12 Correct 14 ms 5528 KB Output is correct
13 Correct 14 ms 5528 KB Output is correct
14 Correct 4 ms 5528 KB Output is correct
15 Correct 4 ms 5528 KB Output is correct
16 Correct 2 ms 5528 KB Output is correct
17 Correct 4 ms 5528 KB Output is correct
18 Correct 2 ms 5528 KB Output is correct
19 Correct 2 ms 5528 KB Output is correct
20 Correct 24 ms 5528 KB Output is correct
21 Correct 4 ms 5528 KB Output is correct
22 Correct 2 ms 5528 KB Output is correct
23 Correct 3 ms 5528 KB Output is correct
24 Correct 4 ms 5528 KB Output is correct
25 Correct 4 ms 5528 KB Output is correct
26 Correct 24 ms 5528 KB Output is correct
27 Correct 24 ms 5528 KB Output is correct
28 Correct 3 ms 5528 KB Output is correct
29 Correct 4 ms 5528 KB Output is correct
30 Correct 3 ms 5528 KB Output is correct
31 Correct 2 ms 5528 KB Output is correct
32 Correct 3 ms 5528 KB Output is correct
33 Correct 4 ms 5528 KB Output is correct
34 Correct 4 ms 5528 KB Output is correct
35 Correct 44 ms 5528 KB Output is correct
36 Correct 7 ms 5528 KB Output is correct
37 Correct 41 ms 5528 KB Output is correct
38 Correct 67 ms 5528 KB Output is correct
39 Correct 79 ms 5528 KB Output is correct
40 Correct 66 ms 5528 KB Output is correct
41 Correct 62 ms 5528 KB Output is correct
42 Execution timed out 1064 ms 5528 KB Time limit exceeded
43 Halted 0 ms 0 KB -