Submission #2898819


Source Code Expand

Copy
lines = $stdin.read
array = lines.split("\n")
N,M = array[0].split(" ").map(&:to_i)

schedules = array[1..M].map.with_index do |str,idx|
  s,t = str.split(" ").map(&:to_i)
  [s,t]
end.sort_by do |job|
  [job.last,job.first]
end

ans,t = 0,0

for i in 0...schedules.length
  #p schedules[i]
  if t <= schedules[i].first
    ans += 1
    t = schedules[i].last
  end
end

p ans

Submission Info

Submission Time
Task D - Islands War
User hiroyuking
Language Ruby (2.3.3)
Score 400
Code Size 397 Byte
Status
Exec Time 634 ms
Memory 22296 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01, sample_02, sample_03
All 400 / 400 0_small_0, 0_small_1, 0_small_10, 0_small_2, 0_small_3, 0_small_4, 0_small_5, 0_small_6, 0_small_7, 0_small_8, 0_small_9, 1_rand_0, 1_rand_1, 1_rand_2, 1_rand_3, 1_rand_4, 1_rand_5, 1_rand_6, 1_rand_7, 1_rand_8, 1_rand_9, 2_max_0, 2_max_1, 2_max_2, 2_max_3, 2_max_4, 2_max_5, 2_max_6, 2_max_7, 2_max_8, 2_max_9, 3_nosub_0, 3_nosub_1, 3_nosub_2, 3_nosub_3, 3_nosub_4, 3_nosub_5, 3_nosub_6, 3_nosub_7, 3_nosub_8, 3_nosub_9, sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
0_small_0 7 ms 1788 KB
0_small_1 7 ms 1788 KB
0_small_10 7 ms 1788 KB
0_small_2 8 ms 1788 KB
0_small_3 7 ms 1788 KB
0_small_4 8 ms 1788 KB
0_small_5 7 ms 1788 KB
0_small_6 7 ms 1788 KB
0_small_7 7 ms 1788 KB
0_small_8 8 ms 1788 KB
0_small_9 7 ms 1788 KB
1_rand_0 28 ms 2556 KB
1_rand_1 226 ms 10744 KB
1_rand_2 528 ms 19704 KB
1_rand_3 535 ms 19832 KB
1_rand_4 75 ms 4344 KB
1_rand_5 457 ms 18680 KB
1_rand_6 233 ms 10872 KB
1_rand_7 444 ms 18424 KB
1_rand_8 173 ms 7544 KB
1_rand_9 511 ms 19448 KB
2_max_0 602 ms 20984 KB
2_max_1 591 ms 20984 KB
2_max_2 606 ms 20984 KB
2_max_3 594 ms 22296 KB
2_max_4 591 ms 20984 KB
2_max_5 605 ms 20984 KB
2_max_6 595 ms 20984 KB
2_max_7 591 ms 20984 KB
2_max_8 595 ms 20984 KB
2_max_9 609 ms 20984 KB
3_nosub_0 619 ms 20984 KB
3_nosub_1 619 ms 20984 KB
3_nosub_2 623 ms 20984 KB
3_nosub_3 634 ms 20984 KB
3_nosub_4 620 ms 20984 KB
3_nosub_5 622 ms 20984 KB
3_nosub_6 616 ms 20984 KB
3_nosub_7 625 ms 20984 KB
3_nosub_8 623 ms 20984 KB
3_nosub_9 615 ms 20984 KB
sample_01 7 ms 1788 KB
sample_02 7 ms 1788 KB
sample_03 7 ms 1788 KB