Official

A - 待ち合わせ場所 / Meeting Place Editorial by admin

GPT 5.4 High

Overview

This problem simply requires extracting the coordinate \(X_K\) of the \(K\)-th building and outputting \(X_K - 1\), which is that value minus \(1\).

In other words, all you need to do is “read the \(K\)-th value.”

Analysis

The key point is that the meeting place is “the point whose coordinate is 1 less than the \(K\)-th building’s coordinate,” as directly stated in the problem.

Therefore, the answer is simply

\(X_K - 1\)

For example, if the building coordinates are

  • \(X_1 = 10\)
  • \(X_2 = 3\)
  • \(X_3 = 20\)

and \(K = 2\), then the landmark is the \(2\)-nd building, so its coordinate is \(3\).
The meeting place is the point \(1\) less than that, so the answer is

\(3 - 1 = 2\)

Points to Watch Out For

In this problem, building numbers and the relative order of coordinates are unrelated.
That is, “the \(K\)-th building” means the building given as the \(K\)-th in the input.

Therefore, operations such as:

  • Sorting by coordinate
  • Finding the minimum or maximum value
  • Calculating distances

are completely unnecessary.

In fact, if you sort, the meaning of building numbers changes, leading to a wrong answer (WA).

Also, coordinates \(X_i\) can range from \(-10^{18}\) to \(10^{18}\), but Python’s integers can handle this range without any issues.

Algorithm

  1. Read \(N, K\)
  2. Read the sequence of building coordinates \(X_1, X_2, \dots, X_N\)
  3. Extract the coordinate \(X_K\) of the \(K\)-th building
  4. Output \(X_K - 1\)

Since Python lists are 0-indexed (the first element has index \(0\)):

  • The \(1\)-st building → X[0]
  • The \(K\)-th building → X[K - 1]

Be careful about this.

Complexity

  • Time complexity: \(O(N)\)
  • Space complexity: \(O(N)\)

Since we need to read \(N\) coordinates as input, the overall complexity is \(O(N)\).
The actual computation itself is extremely lightweight — just referencing the \(K\)-th element and subtracting \(1\).

Implementation Notes

  • \(K\) is 1-indexed, so in Python lists, use X[K - 1]
  • The desired value is simply X[K - 1] - 1
  • No extra processing such as sorting is needed

In this code, we read all input at once and convert it to a sequence of integers:

N, K = data[0], data[1]
X = data[2:2 + N]
print(X[K - 1] - 1)

This gives a simple and clean implementation.

Source Code

import sys

def main():
    data = list(map(int, sys.stdin.read().split()))
    N, K = data[0], data[1]
    X = data[2:2 + N]
    print(X[K - 1] - 1)

if __name__ == "__main__":
    main()

This editorial was generated by gpt-5.4-high.

posted:
last update: