問題一覧 > 通常問題

No.1460 Max of Min

レベル : / AI推定難易度 : 2300 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 33
作問者 : shiomusubi496 / テスター : butsurizuki
お気に入りにしたユーザー ProblemId : 6135 / 自分の提出
問題文最終更新日: 2026-10-22 17:53:18
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
新入生プログラミングコンテスト 2021(夜の部) (順位表) の他の問題:

Note

This problem has a strict time limit, so using a fast language is recommended. (It has been confirmed that the writer's solution gets TLE in Python3 and AC in PyPy3.)

Problem Statement

You are given an integer sequence $B$ of length $K$. Here, define the sequence $A$ as follows.

  • $A_0, A_1, A_2, ... A_{K-1}$ are given
  • For any $i$ with $K\leq i$, $A_i=max(min(A_{i-K},B_0),min(A_{i-K+1},B_1),min(A_{i-K+2},B_2), ... min(A_{i-1},B_{K-1}))$
Given $N$, find $A_N$.

Input

$K\ N$
$A_0\ A_1\ A_2\cdots A_{K-1}$
$B_0\ B_1\ B_2\cdots B_{K-1}$
  • $1\leq K\leq 1000$
  • $0\leq N\leq 10^{18}$
  • $-10^{18}\leq A_i\leq 10^{18}$
  • $-10^{18}\leq B_i\leq 10^{18}$
  • All inputs are integers

Output

Print $A_N$ on one line, followed by a newline.

Sample

Sample 1
Input
2 3
3 1
4 2
Output
2

The sequence $A$ is as follows.

$A_0=3$
$A_1=1$
$A_2=max(min(3,4),min(1,2))=3$
$A_3=max(min(1,4),min(3,2))=2$

Thus $A_3=2$, so print $2$.

Sample 2
Input
1 1000
6
8
Output
6

All elements of $A$ are $6$.

Sample 3
Input
5 10
4390 3289 3280 8032 5814
8231 9107 3289 4361 1332
Output
4390

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。