답안 #1102568

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1102568 2024-10-18T10:25:26 Z YFHHFY Jakarta Skyscrapers (APIO15_skyscraper) C++14
57 / 100
1000 ms 2472 KB
#include<bits/stdc++.h>
#define tizoboz ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
#define int long long
#define itn int
#define ss set <int>
#define prq priority_queue <int>
#define endl '\n'
const ll MOD = 1e9 + 7;
#define md(x) (((x%MOD)+MOD)%MOD)
#define vi vector <int>
#define vl vector<ll>
#define str string 
#define mp make_pair
#define mata int32_t
#define sz size
#define lc id *2
#define rc lc +1
#define SZ(x)           (int)x.size()
#define mid (l+r)/2
#define cn cin
#define ct cout
#define sep " "
#define F first
#define X first
#define S second
#define Y second
using namespace std;
typedef pair <int , int> pii;
const int maxn = 3e4 + 5;
vi g[maxn];
bool use[maxn];
int dist[maxn];
int n , m;
const int inf = 1e9;
void solve(){
    cn >> n >> m;
    vi b(m) , p(m);
    for (int i = 0 ; i < maxn ; i ++) dist[i] = inf;
    for (int i = 0 ; i < m ; i ++){
        cn >> b[i] >> p[i];
        g[b[i]].pb(p[i]);
    }
    int nd = b[0];
    dist[nd] = 0;
    while (!use[b[1]] and nd != -1){
        use[nd] = 1;
        for (auto it : g[nd]){
            for (int j = 1 ; nd + j*it < n ; j++){
                dist[nd+j*it] = min (dist[nd + j*it] , dist[nd] + j);
            }
            for (int j = 1 ; nd-j*it >= 0 ; j++){
                dist[nd -j*it] = min (dist[nd -j*it] , dist[nd] + j);
            }
        }
        nd = -1;
        for (int i = 0 ; i < n ; i++){
            if (use[i]) continue;
            if (dist[i] == 1e9) continue;
            if (nd == -1 || dist[nd] > dist[i]) nd =i;
        }
    }
	if(dist[b[1]]==1e9) dist[b[1]]=-1;
	cout<<dist[b[1]];
}
mata main(){
    tizoboz;
    int tt = 1;
    // cn >> tt;
    while (tt--){
        solve();
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1360 KB Output is correct
2 Correct 2 ms 1360 KB Output is correct
3 Correct 1 ms 1360 KB Output is correct
4 Correct 2 ms 1360 KB Output is correct
5 Correct 1 ms 1360 KB Output is correct
6 Correct 1 ms 1360 KB Output is correct
7 Correct 1 ms 1360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1360 KB Output is correct
2 Correct 1 ms 1360 KB Output is correct
3 Correct 1 ms 1360 KB Output is correct
4 Correct 2 ms 1360 KB Output is correct
5 Correct 1 ms 1360 KB Output is correct
6 Correct 2 ms 1360 KB Output is correct
7 Correct 1 ms 1360 KB Output is correct
8 Correct 2 ms 1528 KB Output is correct
9 Correct 2 ms 1360 KB Output is correct
10 Correct 2 ms 1360 KB Output is correct
11 Correct 1 ms 1360 KB Output is correct
12 Correct 2 ms 1360 KB Output is correct
13 Correct 2 ms 1360 KB Output is correct
14 Correct 2 ms 1360 KB Output is correct
15 Correct 2 ms 1436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1360 KB Output is correct
2 Correct 1 ms 1360 KB Output is correct
3 Correct 1 ms 1360 KB Output is correct
4 Correct 2 ms 1360 KB Output is correct
5 Correct 1 ms 1360 KB Output is correct
6 Correct 1 ms 1360 KB Output is correct
7 Correct 1 ms 1360 KB Output is correct
8 Correct 1 ms 1360 KB Output is correct
9 Correct 2 ms 1528 KB Output is correct
10 Correct 2 ms 1360 KB Output is correct
11 Correct 2 ms 1360 KB Output is correct
12 Correct 2 ms 1360 KB Output is correct
13 Correct 2 ms 1360 KB Output is correct
14 Correct 1 ms 1360 KB Output is correct
15 Correct 1 ms 1420 KB Output is correct
16 Correct 2 ms 1416 KB Output is correct
17 Correct 2 ms 1360 KB Output is correct
18 Correct 1 ms 1360 KB Output is correct
19 Correct 2 ms 1360 KB Output is correct
20 Correct 10 ms 1500 KB Output is correct
21 Correct 1 ms 1360 KB Output is correct
22 Correct 2 ms 1360 KB Output is correct
23 Correct 4 ms 1360 KB Output is correct
24 Correct 6 ms 1360 KB Output is correct
25 Correct 2 ms 1360 KB Output is correct
26 Correct 5 ms 1360 KB Output is correct
27 Correct 7 ms 1360 KB Output is correct
28 Correct 5 ms 1360 KB Output is correct
29 Correct 7 ms 1416 KB Output is correct
30 Correct 6 ms 1528 KB Output is correct
31 Correct 6 ms 1428 KB Output is correct
32 Correct 7 ms 1360 KB Output is correct
33 Correct 7 ms 1360 KB Output is correct
34 Correct 7 ms 1360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1360 KB Output is correct
2 Correct 1 ms 1360 KB Output is correct
3 Correct 1 ms 1360 KB Output is correct
4 Correct 1 ms 1360 KB Output is correct
5 Correct 1 ms 1360 KB Output is correct
6 Correct 1 ms 1360 KB Output is correct
7 Correct 1 ms 1360 KB Output is correct
8 Correct 1 ms 1360 KB Output is correct
9 Correct 1 ms 1360 KB Output is correct
10 Correct 1 ms 1360 KB Output is correct
11 Correct 1 ms 1360 KB Output is correct
12 Correct 1 ms 1360 KB Output is correct
13 Correct 2 ms 1360 KB Output is correct
14 Correct 1 ms 1360 KB Output is correct
15 Correct 1 ms 1360 KB Output is correct
16 Correct 2 ms 1360 KB Output is correct
17 Correct 2 ms 1360 KB Output is correct
18 Correct 2 ms 1360 KB Output is correct
19 Correct 1 ms 1528 KB Output is correct
20 Correct 9 ms 1500 KB Output is correct
21 Correct 1 ms 1360 KB Output is correct
22 Correct 1 ms 1360 KB Output is correct
23 Correct 5 ms 1360 KB Output is correct
24 Correct 5 ms 1360 KB Output is correct
25 Correct 2 ms 1360 KB Output is correct
26 Correct 5 ms 1360 KB Output is correct
27 Correct 6 ms 1464 KB Output is correct
28 Correct 4 ms 1616 KB Output is correct
29 Correct 6 ms 1360 KB Output is correct
30 Correct 6 ms 1404 KB Output is correct
31 Correct 6 ms 1532 KB Output is correct
32 Correct 6 ms 1432 KB Output is correct
33 Correct 7 ms 1360 KB Output is correct
34 Correct 7 ms 1360 KB Output is correct
35 Correct 8 ms 2188 KB Output is correct
36 Correct 3 ms 1360 KB Output is correct
37 Correct 8 ms 1872 KB Output is correct
38 Correct 8 ms 2128 KB Output is correct
39 Correct 5 ms 2128 KB Output is correct
40 Correct 6 ms 2128 KB Output is correct
41 Correct 7 ms 2128 KB Output is correct
42 Correct 7 ms 2128 KB Output is correct
43 Correct 49 ms 2168 KB Output is correct
44 Correct 49 ms 2128 KB Output is correct
45 Correct 10 ms 2296 KB Output is correct
46 Correct 10 ms 2128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1360 KB Output is correct
2 Correct 1 ms 1360 KB Output is correct
3 Correct 1 ms 1360 KB Output is correct
4 Correct 1 ms 1360 KB Output is correct
5 Correct 1 ms 1360 KB Output is correct
6 Correct 1 ms 1360 KB Output is correct
7 Correct 1 ms 1360 KB Output is correct
8 Correct 1 ms 1360 KB Output is correct
9 Correct 2 ms 1360 KB Output is correct
10 Correct 2 ms 1360 KB Output is correct
11 Correct 1 ms 1360 KB Output is correct
12 Correct 2 ms 1360 KB Output is correct
13 Correct 1 ms 1372 KB Output is correct
14 Correct 2 ms 1372 KB Output is correct
15 Correct 1 ms 1476 KB Output is correct
16 Correct 2 ms 1528 KB Output is correct
17 Correct 2 ms 1360 KB Output is correct
18 Correct 2 ms 1360 KB Output is correct
19 Correct 1 ms 1360 KB Output is correct
20 Correct 10 ms 1532 KB Output is correct
21 Correct 1 ms 1360 KB Output is correct
22 Correct 1 ms 1360 KB Output is correct
23 Correct 4 ms 1360 KB Output is correct
24 Correct 5 ms 1360 KB Output is correct
25 Correct 2 ms 1360 KB Output is correct
26 Correct 4 ms 1360 KB Output is correct
27 Correct 6 ms 1360 KB Output is correct
28 Correct 8 ms 1496 KB Output is correct
29 Correct 7 ms 1532 KB Output is correct
30 Correct 7 ms 1360 KB Output is correct
31 Correct 7 ms 1360 KB Output is correct
32 Correct 7 ms 1360 KB Output is correct
33 Correct 9 ms 1360 KB Output is correct
34 Correct 7 ms 1360 KB Output is correct
35 Correct 8 ms 2128 KB Output is correct
36 Correct 2 ms 1360 KB Output is correct
37 Correct 8 ms 2040 KB Output is correct
38 Correct 8 ms 2128 KB Output is correct
39 Correct 6 ms 2128 KB Output is correct
40 Correct 7 ms 2128 KB Output is correct
41 Correct 9 ms 2128 KB Output is correct
42 Correct 8 ms 2128 KB Output is correct
43 Correct 50 ms 2128 KB Output is correct
44 Correct 51 ms 2128 KB Output is correct
45 Correct 11 ms 2296 KB Output is correct
46 Correct 11 ms 2128 KB Output is correct
47 Correct 114 ms 2128 KB Output is correct
48 Correct 6 ms 2128 KB Output is correct
49 Correct 8 ms 2128 KB Output is correct
50 Correct 4 ms 1780 KB Output is correct
51 Execution timed out 1051 ms 2472 KB Time limit exceeded
52 Halted 0 ms 0 KB -