Created
May 19, 2015 01:54
-
-
Save dmiyakawa/5c293d755937866de691 to your computer and use it in GitHub Desktop.
POJ No.1852 「Ants」問題文 (抜粋和訳)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
長さLcmの竿の上をn匹のアリが毎秒1cmのスピードで歩いています。 | |
アリが竿の端に到達すると竿の下に落ちていきます。 | |
また、竿の上は狭くてすれ違えないので、 | |
二匹のアリが出会うと、それぞれ反対を向いて戻っていきます。 | |
各アリについて、現在の竿の左端からの距離x_iはわかりますが、 | |
どちらの方向を向いているのかはわかりません。 | |
すべてのアリが竿から落ちるまでにかかる最小の時間と最大の時間をそれぞれ求めなさい。 | |
制約 | |
1 <= L <= 10^6 | |
1 <= n <= 10^6 | |
0 <= x[i] <= L | |
『プログラミングコンテストチャレンジブック』(初版)より |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
例:
L = 10
n = 3
x = {2, 6, 7}
答え
min = 4
max = 8