Submission #19868078
Source Code Expand
Copy
n, k = gets.chomp.split(' ').map(&:to_i) p = gets.chomp.split(' ').map(&:to_i) max = [] min = [] k.times do |i| until max.empty? break if max.first[0] > p[i] max.shift end until min.empty? break if min.first[0] < p[i] min.shift end max << [p[i], i] min << [p[i], i] end ans = 1 k.upto(n - 1) do |i| mi = [10 ** 18, 10 ** 18] max.shift if !max.empty? && i - max.first[1] >= k mi = min.shift if !min.empty? && i - min.first[1] >= k until max.empty? break if max.first[0] > p[i] max.shift end until min.empty? break if min.first[0] < p[i] min.shift end max << [p[i], i] min << [p[i], i] ans += 1 unless mi[1] != 10 ** 18 && max.first[1] == i end puts ans
Submission Info
Submission Time | |
---|---|
Task | B - Sorting a Segment |
User | coco18000 |
Language | Ruby (2.7.1) |
Score | 0 |
Code Size | 765 Byte |
Status | WA |
Exec Time | 233 ms |
Memory | 47200 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 700 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 64 ms | 13944 KB |
01-02.txt | AC | 61 ms | 14020 KB |
01-03.txt | AC | 199 ms | 32672 KB |
01-04.txt | WA | 192 ms | 33256 KB |
01-05.txt | WA | 142 ms | 28732 KB |
01-06.txt | AC | 172 ms | 31112 KB |
01-07.txt | AC | 214 ms | 34004 KB |
01-08.txt | WA | 233 ms | 34020 KB |
01-09.txt | WA | 210 ms | 34060 KB |
01-10.txt | WA | 222 ms | 34048 KB |
01-11.txt | WA | 230 ms | 34172 KB |
01-12.txt | WA | 216 ms | 34300 KB |
01-13.txt | WA | 219 ms | 34124 KB |
01-14.txt | AC | 227 ms | 34892 KB |
01-15.txt | WA | 213 ms | 34604 KB |
01-16.txt | WA | 221 ms | 34820 KB |
01-17.txt | AC | 228 ms | 44612 KB |
01-18.txt | WA | 206 ms | 40284 KB |
01-19.txt | WA | 213 ms | 40300 KB |
01-20.txt | AC | 210 ms | 35260 KB |
01-21.txt | AC | 199 ms | 40736 KB |
01-22.txt | AC | 213 ms | 47200 KB |
01-23.txt | WA | 187 ms | 40896 KB |
01-24.txt | WA | 201 ms | 41000 KB |
01-25.txt | AC | 176 ms | 41900 KB |
01-26.txt | AC | 188 ms | 41384 KB |
01-27.txt | AC | 197 ms | 39876 KB |
01-28.txt | AC | 172 ms | 41348 KB |
01-29.txt | AC | 173 ms | 41052 KB |
sample-01.txt | AC | 61 ms | 14124 KB |
sample-02.txt | AC | 62 ms | 13988 KB |
sample-03.txt | AC | 60 ms | 14036 KB |