提出 #7646328
ソースコード 拡げる
N, K = gets.split.map(&:to_i)
P = gets.split.map(&:to_i)
IsPM = lambda{|i|
return (i...(i+K-1)).all?{|j|
P[j] < P[j+1]
}
}
PopIsMin = lambda{|i|
return P[i+1,K-1].all?{|_| P[i] < _ }
}
PushIsMax = lambda{|i|
return P[i-K+1,K-1].all?{|_| _ < P[i] }
}
pm, n = IsPM[0] ? [1, 0] : [0, 1]
(N-K).times{|i|
if IsPM[i+1]
pm += 1
elsif ! PopIsMin[i] or ! PushIsMax[i+K]
n += 1
end
}
p n+[pm,1].min
提出情報
| 提出日時 | |
|---|---|
| 問題 | B - Sorting a Segment |
| ユーザ | ds14050 |
| 言語 | Ruby (2.3.3) |
| 得点 | 0 |
| コード長 | 430 Byte |
| 結果 | TLE |
| 実行時間 | 2108 ms |
| メモリ | 21284 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 0 / 700 | ||||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | sample-01.txt, sample-02.txt, sample-03.txt |
| All | 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, sample-01.txt, sample-02.txt, sample-03.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 01-01.txt | AC | 7 ms | 1788 KiB |
| 01-02.txt | AC | 7 ms | 1788 KiB |
| 01-03.txt | AC | 370 ms | 13068 KiB |
| 01-04.txt | TLE | 2108 ms | 13324 KiB |
| 01-05.txt | TLE | 2108 ms | 10764 KiB |
| 01-06.txt | TLE | 2108 ms | 10508 KiB |
| 01-07.txt | AC | 354 ms | 19212 KiB |
| 01-08.txt | AC | 406 ms | 19212 KiB |
| 01-09.txt | AC | 260 ms | 19212 KiB |
| 01-10.txt | AC | 593 ms | 19212 KiB |
| 01-11.txt | AC | 434 ms | 19212 KiB |
| 01-12.txt | TLE | 2108 ms | 21284 KiB |
| 01-13.txt | TLE | 2108 ms | 19212 KiB |
| 01-14.txt | AC | 472 ms | 19212 KiB |
| 01-15.txt | TLE | 2108 ms | 16140 KiB |
| 01-16.txt | TLE | 2108 ms | 15628 KiB |
| 01-17.txt | AC | 284 ms | 19212 KiB |
| 01-18.txt | TLE | 2108 ms | 15372 KiB |
| 01-19.txt | TLE | 2108 ms | 17316 KiB |
| 01-20.txt | TLE | 2108 ms | 15244 KiB |
| 01-21.txt | TLE | 2108 ms | 15244 KiB |
| 01-22.txt | AC | 205 ms | 19212 KiB |
| 01-23.txt | TLE | 2108 ms | 15244 KiB |
| 01-24.txt | TLE | 2108 ms | 15372 KiB |
| 01-25.txt | TLE | 2108 ms | 17316 KiB |
| 01-26.txt | TLE | 2108 ms | 15244 KiB |
| 01-27.txt | AC | 86 ms | 15244 KiB |
| 01-28.txt | AC | 106 ms | 15244 KiB |
| 01-29.txt | AC | 90 ms | 15244 KiB |
| sample-01.txt | AC | 7 ms | 1788 KiB |
| sample-02.txt | AC | 7 ms | 1788 KiB |
| sample-03.txt | AC | 7 ms | 1788 KiB |