Submission #506683

# Submission time Handle Problem Language Result Execution time Memory
506683 2022-01-12T06:21:59 Z Aldas25 Jakarta Skyscrapers (APIO15_skyscraper) C++14
36 / 100
1000 ms 33120 KB
#include <bits/stdc++.h>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;

const int MAXN = 30100;

int n, m;
int b[MAXN], p[MAXN];
vii adj[MAXN];
int d[MAXN];
priority_queue<pii, vii, greater<pii>> q;
bool vis[MAXN];

void dijkstra () {
    FOR(i, 0, m-1) d[i] = -1;
    d[0] = 0;
    q.push({d[0], 0});

    while (!q.empty()) {
        int v = q.top().s;
        q.pop();
        if (vis[v]) continue;
        vis[v] = true;

        for (auto p : adj[v]) {
            int w = p.s;
            int u = p.f;
            if (d[u] == -1 || d[u] > d[v]+w) {
                d[u] = d[v]+w;
                q.push({d[u], u});
            }
        }
    }
}

int main()
{
    FAST_IO;

    cin >> n >> m;
    FOR(i, 0, m-1) cin >> b[i] >> p[i];

    FOR(i, 0, m-1) FOR(j, 0, m-1) {
        int d = abs(b[j] - b[i]);
        if (d % p[i]) continue;
        int x = d / p[i];
        adj[i].pb({j, x});
    }

    dijkstra();

    cout << d[1] << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 1 ms 1036 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 1 ms 972 KB Output is correct
6 Correct 1 ms 972 KB Output is correct
7 Correct 1 ms 972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 1 ms 972 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 1 ms 972 KB Output is correct
6 Correct 1 ms 972 KB Output is correct
7 Correct 1 ms 968 KB Output is correct
8 Correct 1 ms 972 KB Output is correct
9 Correct 1 ms 972 KB Output is correct
10 Correct 2 ms 1228 KB Output is correct
11 Correct 23 ms 3184 KB Output is correct
12 Correct 60 ms 32880 KB Output is correct
13 Correct 61 ms 33104 KB Output is correct
14 Correct 24 ms 2480 KB Output is correct
15 Correct 25 ms 2540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 1 ms 972 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 1 ms 972 KB Output is correct
6 Correct 1 ms 972 KB Output is correct
7 Correct 1 ms 972 KB Output is correct
8 Correct 1 ms 972 KB Output is correct
9 Correct 1 ms 972 KB Output is correct
10 Correct 2 ms 1100 KB Output is correct
11 Correct 24 ms 3164 KB Output is correct
12 Correct 57 ms 32940 KB Output is correct
13 Correct 57 ms 33092 KB Output is correct
14 Correct 23 ms 2500 KB Output is correct
15 Correct 24 ms 2456 KB Output is correct
16 Correct 5 ms 1228 KB Output is correct
17 Correct 19 ms 1728 KB Output is correct
18 Correct 5 ms 1076 KB Output is correct
19 Correct 2 ms 972 KB Output is correct
20 Correct 56 ms 33092 KB Output is correct
21 Correct 8 ms 1100 KB Output is correct
22 Correct 3 ms 972 KB Output is correct
23 Correct 5 ms 1100 KB Output is correct
24 Correct 19 ms 1228 KB Output is correct
25 Correct 21 ms 1144 KB Output is correct
26 Correct 54 ms 30104 KB Output is correct
27 Correct 54 ms 30992 KB Output is correct
28 Correct 20 ms 1228 KB Output is correct
29 Correct 4 ms 1356 KB Output is correct
30 Correct 1 ms 972 KB Output is correct
31 Correct 2 ms 1100 KB Output is correct
32 Correct 2 ms 1100 KB Output is correct
33 Correct 23 ms 2480 KB Output is correct
34 Correct 24 ms 2508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 1 ms 972 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 1 ms 1008 KB Output is correct
6 Correct 1 ms 972 KB Output is correct
7 Correct 1 ms 972 KB Output is correct
8 Correct 1 ms 972 KB Output is correct
9 Correct 1 ms 972 KB Output is correct
10 Correct 2 ms 1100 KB Output is correct
11 Correct 28 ms 3268 KB Output is correct
12 Correct 59 ms 32964 KB Output is correct
13 Correct 64 ms 33080 KB Output is correct
14 Correct 22 ms 2508 KB Output is correct
15 Correct 25 ms 2508 KB Output is correct
16 Correct 5 ms 1228 KB Output is correct
17 Correct 17 ms 1620 KB Output is correct
18 Correct 6 ms 1100 KB Output is correct
19 Correct 2 ms 972 KB Output is correct
20 Correct 60 ms 33064 KB Output is correct
21 Correct 7 ms 1100 KB Output is correct
22 Correct 3 ms 972 KB Output is correct
23 Correct 6 ms 1104 KB Output is correct
24 Correct 20 ms 1228 KB Output is correct
25 Correct 20 ms 1160 KB Output is correct
26 Correct 54 ms 30048 KB Output is correct
27 Correct 54 ms 31020 KB Output is correct
28 Correct 20 ms 1252 KB Output is correct
29 Correct 5 ms 1228 KB Output is correct
30 Correct 1 ms 972 KB Output is correct
31 Correct 3 ms 1100 KB Output is correct
32 Correct 2 ms 1100 KB Output is correct
33 Correct 23 ms 2508 KB Output is correct
34 Correct 24 ms 2536 KB Output is correct
35 Execution timed out 1086 ms 11988 KB Time limit exceeded
36 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 1 ms 972 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 1 ms 972 KB Output is correct
6 Correct 1 ms 972 KB Output is correct
7 Correct 1 ms 972 KB Output is correct
8 Correct 1 ms 972 KB Output is correct
9 Correct 1 ms 972 KB Output is correct
10 Correct 2 ms 1100 KB Output is correct
11 Correct 27 ms 3232 KB Output is correct
12 Correct 56 ms 32976 KB Output is correct
13 Correct 59 ms 33120 KB Output is correct
14 Correct 25 ms 2504 KB Output is correct
15 Correct 24 ms 2476 KB Output is correct
16 Correct 5 ms 1228 KB Output is correct
17 Correct 19 ms 1752 KB Output is correct
18 Correct 6 ms 1100 KB Output is correct
19 Correct 2 ms 972 KB Output is correct
20 Correct 56 ms 33092 KB Output is correct
21 Correct 7 ms 1100 KB Output is correct
22 Correct 4 ms 972 KB Output is correct
23 Correct 6 ms 1088 KB Output is correct
24 Correct 19 ms 1160 KB Output is correct
25 Correct 22 ms 1176 KB Output is correct
26 Correct 56 ms 30136 KB Output is correct
27 Correct 54 ms 30916 KB Output is correct
28 Correct 21 ms 1268 KB Output is correct
29 Correct 4 ms 1228 KB Output is correct
30 Correct 1 ms 972 KB Output is correct
31 Correct 3 ms 1100 KB Output is correct
32 Correct 2 ms 1100 KB Output is correct
33 Correct 23 ms 2476 KB Output is correct
34 Correct 22 ms 2448 KB Output is correct
35 Execution timed out 1100 ms 11788 KB Time limit exceeded
36 Halted 0 ms 0 KB -