PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CCBCHBAHAI0000018. Khoảng cách giữa hai phần tử theo chỉ số (Distance Between Two Indexed Elements)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Khoảng cách giữa hai phần tử theo chỉ số (Distance Between Two Indexed Elements)
Distance Between Two Indexed Elements
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
You are given an integer array of length , indexed from to , and two distinct valid indices . In this PHOJ specification, the distance between the two indexed elements is defined as the absolute difference of their values:
Compute .
Input
- The first line contains three integers , , and . Indices are 0-based.
- The second line contains exactly integers .
Output
Print one integer .
Subtasks
Subtask 1 (20 points): , , , .
Subtask 2 (30 points): , , .
Subtask 3 (50 points): , , , .
Examples
Input
5 1 4
8 6 7 5 -3
Output
9
Explanation
The indices are and . We have and . Thus
The output is 9.