답안 #1028614

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1028614 2024-07-20T06:10:08 Z vjudge1 Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
1000 ms 1884 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 30010, M = 30010;
int n, m, b[M], p[M], dist[N];
bool mark[N];
vector<int> vec[N];

int main(){
    cin >> n >> m;
    for (int i = 0; i < m; i ++){
        cin >> b[i] >> p[i];
        vec[b[i]].push_back(p[i]);
    }
    for (int i = 0; i < n; i ++){
        sort(vec[i].begin(), vec[i].end());
        vec[i].resize(unique(vec[i].begin(), vec[i].end()) - vec[i].begin());
    }

    memset(dist, 63, sizeof dist);
    dist[b[0]] = 0;

    for (int ii = 0; ii < n; ii ++){
        int v = -1;
        for (int j = 0; j < n; j ++)
            if (!mark[j] and (v == -1 or dist[v] > dist[j]))
                v = j;

        if (v == b[1]) break;

        mark[v] = 1;
        for (int d : vec[v]){
            for (int i = 1; v + d * i < n and dist[v] + i < dist[b[1]]; i ++)
                dist[v + d * i] = min(dist[v + d * i], dist[v] + i);
            for (int i = 1; v - d * i >= 0 and dist[v] + i < dist[b[1]]; i ++)
                dist[v - d * i] = min(dist[v - d * i], dist[v] + i);
        }
    }

    if (dist[b[1]] > 1e9)
        dist[b[1]] = -1;
    cout << dist[b[1]] << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 0 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 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1116 KB Output is correct
2 Correct 0 ms 1116 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 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 1 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1112 KB Output is correct
14 Correct 1 ms 1112 KB Output is correct
15 Correct 1 ms 1180 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 1368 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 1 ms 1112 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 1112 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 2 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 5 ms 1116 KB Output is correct
19 Correct 5 ms 1116 KB Output is correct
20 Correct 9 ms 1116 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 5 ms 1292 KB Output is correct
23 Correct 4 ms 1300 KB Output is correct
24 Correct 6 ms 1116 KB Output is correct
25 Correct 3 ms 1116 KB Output is correct
26 Correct 6 ms 1116 KB Output is correct
27 Correct 6 ms 1116 KB Output is correct
28 Correct 7 ms 1344 KB Output is correct
29 Correct 7 ms 1244 KB Output is correct
30 Correct 6 ms 1268 KB Output is correct
31 Correct 7 ms 1116 KB Output is correct
32 Correct 6 ms 1116 KB Output is correct
33 Correct 7 ms 1116 KB Output is correct
34 Correct 7 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 1116 KB Output is correct
5 Correct 0 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 1112 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 1 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 2 ms 1116 KB Output is correct
18 Correct 5 ms 1128 KB Output is correct
19 Correct 5 ms 1116 KB Output is correct
20 Correct 9 ms 1116 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 5 ms 1160 KB Output is correct
23 Correct 4 ms 1116 KB Output is correct
24 Correct 6 ms 1116 KB Output is correct
25 Correct 3 ms 1116 KB Output is correct
26 Correct 7 ms 1116 KB Output is correct
27 Correct 6 ms 1116 KB Output is correct
28 Correct 7 ms 1116 KB Output is correct
29 Correct 7 ms 1116 KB Output is correct
30 Correct 6 ms 1116 KB Output is correct
31 Correct 6 ms 1116 KB Output is correct
32 Correct 7 ms 1112 KB Output is correct
33 Correct 8 ms 1300 KB Output is correct
34 Correct 7 ms 1116 KB Output is correct
35 Correct 13 ms 1624 KB Output is correct
36 Correct 3 ms 1116 KB Output is correct
37 Correct 10 ms 1508 KB Output is correct
38 Correct 11 ms 1624 KB Output is correct
39 Correct 9 ms 1628 KB Output is correct
40 Correct 9 ms 1628 KB Output is correct
41 Correct 14 ms 1628 KB Output is correct
42 Correct 13 ms 1628 KB Output is correct
43 Correct 13 ms 1752 KB Output is correct
44 Correct 16 ms 1752 KB Output is correct
45 Correct 15 ms 1508 KB Output is correct
46 Correct 14 ms 1624 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 0 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 0 ms 1116 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 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 1 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 2 ms 1116 KB Output is correct
18 Correct 5 ms 1112 KB Output is correct
19 Correct 5 ms 1116 KB Output is correct
20 Correct 9 ms 1348 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 5 ms 1116 KB Output is correct
23 Correct 5 ms 1116 KB Output is correct
24 Correct 6 ms 1172 KB Output is correct
25 Correct 3 ms 1116 KB Output is correct
26 Correct 6 ms 1116 KB Output is correct
27 Correct 7 ms 1112 KB Output is correct
28 Correct 7 ms 1112 KB Output is correct
29 Correct 7 ms 1116 KB Output is correct
30 Correct 7 ms 1268 KB Output is correct
31 Correct 7 ms 1116 KB Output is correct
32 Correct 6 ms 1276 KB Output is correct
33 Correct 7 ms 1296 KB Output is correct
34 Correct 7 ms 1300 KB Output is correct
35 Correct 11 ms 1628 KB Output is correct
36 Correct 3 ms 1116 KB Output is correct
37 Correct 10 ms 1528 KB Output is correct
38 Correct 11 ms 1520 KB Output is correct
39 Correct 9 ms 1628 KB Output is correct
40 Correct 9 ms 1552 KB Output is correct
41 Correct 11 ms 1628 KB Output is correct
42 Correct 12 ms 1620 KB Output is correct
43 Correct 13 ms 1584 KB Output is correct
44 Correct 15 ms 1628 KB Output is correct
45 Correct 14 ms 1564 KB Output is correct
46 Correct 14 ms 1708 KB Output is correct
47 Correct 131 ms 1784 KB Output is correct
48 Correct 400 ms 1880 KB Output is correct
49 Correct 620 ms 1872 KB Output is correct
50 Correct 830 ms 1728 KB Output is correct
51 Execution timed out 1074 ms 1884 KB Time limit exceeded
52 Halted 0 ms 0 KB -