Submission #2879237


Source Code Expand

Copy
N, M = gets.split.map(&:to_i)
ab = []
M.times do |i|
    ab[i] = gets.split.map(&:to_i)
end
ab.sort_by!{|arr| arr[1]}

ans = 0
last = -1
ab.each do |a, b|
    if last <= a
        ans += 1
        last = b
    end
end
puts ans

Submission Info

Submission Time
Task D - Islands War
User betrue12
Language Ruby (2.3.3)
Score 400
Code Size 241 Byte
Status
Exec Time 233 ms
Memory 12664 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 7 ms 1788 KB
0_small_3 7 ms 1788 KB
0_small_4 7 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 7 ms 1788 KB
0_small_9 7 ms 1788 KB
1_rand_0 16 ms 2296 KB
1_rand_1 93 ms 6136 KB
1_rand_2 206 ms 12280 KB
1_rand_3 208 ms 12280 KB
1_rand_4 35 ms 3192 KB
1_rand_5 180 ms 10616 KB
1_rand_6 97 ms 6392 KB
1_rand_7 171 ms 9720 KB
1_rand_8 72 ms 4984 KB
1_rand_9 201 ms 12152 KB
2_max_0 232 ms 12664 KB
2_max_1 228 ms 12664 KB
2_max_2 230 ms 12664 KB
2_max_3 231 ms 12664 KB
2_max_4 229 ms 12664 KB
2_max_5 228 ms 12664 KB
2_max_6 229 ms 12664 KB
2_max_7 229 ms 12664 KB
2_max_8 229 ms 12664 KB
2_max_9 228 ms 12664 KB
3_nosub_0 218 ms 12408 KB
3_nosub_1 220 ms 12408 KB
3_nosub_2 219 ms 12408 KB
3_nosub_3 219 ms 12408 KB
3_nosub_4 220 ms 12408 KB
3_nosub_5 221 ms 12408 KB
3_nosub_6 222 ms 12408 KB
3_nosub_7 233 ms 12408 KB
3_nosub_8 226 ms 12408 KB
3_nosub_9 221 ms 12408 KB
sample_01 7 ms 1788 KB
sample_02 7 ms 1788 KB
sample_03 7 ms 1788 KB