답안 #1047451

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1047451 2024-08-07T13:15:08 Z SN0WM4N 밀림 점프 (APIO21_jumps) C++14
0 / 100
4000 ms 3512 KB
#include "jumps.h"

#include <bits/stdc++.h>
using namespace std;

vector<int> v;
vector<int> m_sig;

void init(int N, std::vector<int> H) {
        v = H;
        m_sig.resize(N);

        int mx = 1e9, idx = -1;

        for (int i = N - 1; i >= 0; i --) {
                m_sig[i] = i;
                for (int j = i; j < N; j ++) {
                        if (H[j] > H[i]) {
                                m_sig[i] = j;
                                break;
                        }
                }
        }
}

int minimum_jumps(int A, int B, int C, int D) {
        int mx = -1, idx = -1;
        for (int i = A; i <= B; i ++) {
                if (v[i] > mx) {
                        mx = v[i];
                        idx = i;
                }
        }

        int ans = 0;
        while (idx < C) {
                ans ++;
                if (idx == m_sig[idx])
                        break;
                idx = m_sig[idx];
        }

        if (C <= idx && idx <= D) 
                return ans;
        return -1;
}

Compilation message

jumps.cpp: In function 'void init(int, std::vector<int>)':
jumps.cpp:13:13: warning: unused variable 'mx' [-Wunused-variable]
   13 |         int mx = 1e9, idx = -1;
      |             ^~
jumps.cpp:13:23: warning: unused variable 'idx' [-Wunused-variable]
   13 |         int mx = 1e9, idx = -1;
      |                       ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 969 ms 2844 KB Output is correct
4 Execution timed out 4080 ms 3416 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Incorrect 1 ms 344 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Incorrect 1 ms 344 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 12 ms 2904 KB Output is correct
6 Correct 14 ms 3492 KB Output is correct
7 Correct 8 ms 1880 KB Output is correct
8 Correct 15 ms 3504 KB Output is correct
9 Correct 3 ms 680 KB Output is correct
10 Correct 17 ms 3512 KB Output is correct
11 Correct 15 ms 3508 KB Output is correct
12 Incorrect 12 ms 3416 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Incorrect 110 ms 1864 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Incorrect 110 ms 1864 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 969 ms 2844 KB Output is correct
4 Execution timed out 4080 ms 3416 KB Time limit exceeded
5 Halted 0 ms 0 KB -