답안 #1027347

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1027347 2024-07-19T03:53:32 Z Muhammet Jakarta Skyscrapers (APIO15_skyscraper) C++17
36 / 100
1000 ms 1884 KB
#include <bits/stdc++.h>
using namespace std;

#define N 30001
#define ll long long int
#define sz(x) (int)x.size()
#define ff first
#define ss second

const ll M = 30000000;

ll T, n, m, b[N], p[N], d[N];

int main(){
    ios::sync_with_stdio(false); cin.tie(0);

    cin >> n >> m;

    for(int i = 0; i < m; i++){
    	cin >> b[i] >> p[i];
        d[i] = M;
    }
    d[0] = 0;
    ll x = 0;
    vector <ll> v;
    for(int i = 1; i < m; i++) v.push_back(i);
    while(sz(v) > 0){
        ll mn = M, ind = x;
        for(auto i : v){
            ll k = (abs(b[i]-b[x]));
            if(d[i] < mn) ind = i;
            mn = min(d[i],mn);
            if(k % p[x] != 0) continue;
            d[i] = min(d[x] + (k/p[x]), d[i]);
            if(d[i] < mn) ind = i;
            mn = min(d[i],mn);
        }
        if(x == ind) break;
        x = ind;
    	if(x == 1) break;
        for(int i = 0; i < sz(v); i++){
        	if(v[i] == ind){
        		v.erase(v.begin() + i);
        		break;
        	}
        }
    }

    if(d[1] == M) d[1] = -1;
    cout << d[1];

    return 0;
}   
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 5 ms 564 KB Output is correct
14 Correct 6 ms 348 KB Output is correct
15 Correct 6 ms 568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 5 ms 508 KB Output is correct
14 Correct 6 ms 348 KB Output is correct
15 Correct 6 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 4 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 6 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 468 KB Output is correct
23 Correct 2 ms 348 KB Output is correct
24 Correct 5 ms 348 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 6 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 6 ms 348 KB Output is correct
34 Correct 6 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 5 ms 564 KB Output is correct
14 Correct 6 ms 348 KB Output is correct
15 Correct 6 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 4 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 472 KB Output is correct
20 Correct 5 ms 568 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 5 ms 348 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 6 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 6 ms 348 KB Output is correct
34 Correct 6 ms 348 KB Output is correct
35 Correct 725 ms 1628 KB Output is correct
36 Correct 8 ms 604 KB Output is correct
37 Correct 102 ms 1372 KB Output is correct
38 Correct 421 ms 1760 KB Output is correct
39 Correct 5 ms 1756 KB Output is correct
40 Correct 23 ms 1780 KB Output is correct
41 Correct 251 ms 1760 KB Output is correct
42 Correct 4 ms 1624 KB Output is correct
43 Correct 13 ms 1628 KB Output is correct
44 Execution timed out 1004 ms 1628 KB Time limit exceeded
45 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 460 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 5 ms 596 KB Output is correct
14 Correct 6 ms 348 KB Output is correct
15 Correct 7 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 4 ms 560 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 6 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 5 ms 472 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 6 ms 572 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 460 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 6 ms 348 KB Output is correct
34 Correct 6 ms 564 KB Output is correct
35 Correct 757 ms 1628 KB Output is correct
36 Correct 8 ms 600 KB Output is correct
37 Correct 105 ms 1372 KB Output is correct
38 Correct 412 ms 1788 KB Output is correct
39 Correct 5 ms 1756 KB Output is correct
40 Correct 26 ms 1756 KB Output is correct
41 Correct 260 ms 1808 KB Output is correct
42 Correct 5 ms 1760 KB Output is correct
43 Correct 14 ms 1628 KB Output is correct
44 Execution timed out 1094 ms 1884 KB Time limit exceeded
45 Halted 0 ms 0 KB -