#5863. [CEOI 2025] highest
[CEOI 2025] highest
[CEOI 2025] highest
题目描述
In an alternate universe, Vlad is stuck inside a futuristic version of the Poenari Fortress, now spanning $n$ floors, numbered $0$ through $n - 1$. From each floor $i$ ($0 \leq i \leq n - 1$), he can only go up, either by taking the stairs and paying $1$ drop of blood (this is the currency that vampires use to pay in Romania), or by turning into a bat and traversing the vents, for which he has to pay $2$ drops of blood. The stairs can take him up to $v[i]$ floors upwards, while the vents span up to $w[i]$ floors upwards, where $v$ and $w$ are two given arrays: $v = v[0], v[1], \ldots, v[n - 1]$ and $w = w[0], w[1], \ldots, w[n - 1]$.Formally, from floor (), Vlad can go:
- anywhere from floor to floor without exceeding , for a cost of
- anywhere from floor to floor without exceeding , for a cost of
Furthermore, his brothers Radu and Mircea proposed scenarios for Vlad, each one consisting of two floors and (). Vlad has to answer their questions: what is the least amount of blood that he has to sacrifice to get from floor to floor ?
Implementation Details
You will have to implement the function solve:
std::vector<int> solve(std::vector<int> &v, std::vector<int> &w, std::vector<std::pair<int,int>> &queries);
- Receives the vectors , the heights of the flights of stairs, and , the heights of the vent systems, starting at each floor, both of them of size .
- Also receives the queries, a vector of pairs of size . Each pair contains and as described in the statement.
- Returns a vector of size , consisting of the answers to the queries.
输入格式
(暂无输入格式说明)输出格式
(暂无输出格式说明)7
2 3 1 1 1 1 2
3 4 1 2 1 2 2
3
0 4
0 5
0 6
2
3
4
10
1 1 1 2 3 2 1 1 2 3
2 4 1 4 1 4 1 3 2 3
5
3 9
0 9
0 7
0 4
3 5
3
5
4
3
1
提示
### Sample Explanation 1Consider the following call:
solve({2, 3, 1, 1, 1, 1, 2}, {3, 4, 1, 2, 1, 2, 2}, {{0, 4}, {0, 5}, {0, 6}})
Here we have and queries, and .
For the first query , Vlad has to make two -cost jumps: to (even though he can jump to , floor will then take him further), then to . Total cost: .
For the second query , there are optimal paths: to (cost ), to (cost ), to (cost ); the second path is to (cost ), to (cost ). Total cost: .
For the third query , one example path of cost is to (cost ), to (cost ), to (cost ). Total cost: .
So the vector that the function will return must be:
Sample Explanation 2
Consider the following call:
solve({1, 1, 1, 2, 3, 2, 1, 1, 2, 3}, {2, 4, 1, 4, 1, 4, 1, 3, 2, 3}, {{3, 9}, {0, 9}, {0, 7}, {0, 4}, {3, 5}})
These are the optimal paths for the queries:
- : to (cost ), to (cost ) total:
- : to (cost ), to (cost ), to (cost ) total:
- : to (cost ), to (cost ), to (cost ) total:
- : to (cost ), to (cost ) total:
- : to (cost ) total:
So the vector that the function will return must be:
Constraints
- for all
- for all queries
Subtasks
- (5 points)
- (7 points)
- (11 points)
- (44 points)
- (8 points) $1 \leq n \leq 500000, 1 \leq m \leq 500000, v[i] \leq v[j]$ and for all
- (25 points) No further restrictions 标签: P13691|倍增|2025|交互题|CEOI(中欧)|ST 表