제출 #565175

#제출 시각아이디문제언어결과실행 시간메모리
565175turbileg밀림 점프 (APIO21_jumps)C++14
0 / 100
4022 ms2636 KiB
#include <bits/stdc++.h> #include "jumps.h" #include <vector> std::vector<int> H; std::vector<int> v; int a[200005]; int ans; int n; void init(int N, std::vector<int> H) { v = H; n = N; } int minimum_jumps(int A, int B, int C, int D) { for (int i = 0; i < n; i++) { int x = -1e6, y = 1e6; if (v[i] == n) { v[i] = n; continue; } for (int j = i - 1; j >= 0; j--) { if(v[j] > v[i]) { x = j; break; } } for (int j = i + 1; j < n; j++) { if(v[j] > v[i]) { y = j; break; } } if(y - i > i - x) a[i] = x; else if(y - i < i - x) a[i] = y; else { if (v[x] > v[y]) a[i] = x; else a[i] = y; } } int mx = 0; for (int i = C; i <= D; i++) { if(v[i] > mx) mx = v[i]; } int ans = 1e6; for(int i = A; i <= B; i++) { int p = i; int res = 0; while (p < n) { res ++; p = a[p]; if(C <= p && p <= D) { if(ans > res) { ans = res; } break; } if(v[p] > mx) break; } } if (ans == 1e6) return -1; else return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...