Submission #33764473


Source Code Expand

Copy
use std::collections::BTreeSet;
use proconio::input;
fn main() {
input! {
n: usize,
ab: [(usize, usize); n],
cd: [(usize, usize); n],
};
// 0: red, 1: blue
let mut pt = ab
.into_iter()
.map(|(a, b)| (a, b, 0))
.chain(cd.into_iter().map(|(c, d)| (c, d, 1)))
.collect::<Vec<(usize, usize, usize)>>();
pt.sort_by_key(|&(x, y, c)| (x, c, y));
let mut count = 0_usize;
let mut ry = BTreeSet::new();
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
use std::collections::BTreeSet;

use proconio::input;

fn main() {
    input! {
        n: usize,
        ab: [(usize, usize); n],
        cd: [(usize, usize); n],
    };

    // 0: red, 1: blue
    let mut pt = ab
        .into_iter()
        .map(|(a, b)| (a, b, 0))
        .chain(cd.into_iter().map(|(c, d)| (c, d, 1)))
        .collect::<Vec<(usize, usize, usize)>>();
    pt.sort_by_key(|&(x, y, c)| (x, c, y));

    let mut count = 0_usize;
    let mut ry = BTreeSet::new();
    for (_, y, c) in pt {
        match c {
            0 => {
                ry.insert(y);
            }
            1 => {
                if let Some(&ty) = ry.range(0..y).rev().next() {
                    count += 1;
                    ry.remove(&ty);
                }
            }
            _ => unreachable!(),
        }
    }

    let ans = count;
    println!("{}", ans);
}

Submission Info

Submission Time
Task C - 2D Plane 2N Points
User bouzuya
Language Rust (1.42.0)
Score 400
Code Size 871 Byte
Status AC
Exec Time 6 ms
Memory 2208 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 5
AC × 17
Set Name Test Cases
Sample example_0, example_1, example_2, example_3, example_4
All example_0, example_1, example_2, example_3, example_4, line_0, line_1, line_2, line_3, maxrand_0, maxrand_1, maxrand_2, maxrand_3, maxrand_4, rand_0, rand_1, rand_2
Case Name Status Exec Time Memory
example_0 AC 6 ms 2208 KB
example_1 AC 1 ms 2096 KB
example_2 AC 1 ms 2100 KB
example_3 AC 1 ms 2000 KB
example_4 AC 1 ms 2088 KB
line_0 AC 1 ms 2092 KB
line_1 AC 1 ms 2104 KB
line_2 AC 1 ms 2064 KB
line_3 AC 2 ms 2112 KB
maxrand_0 AC 2 ms 2052 KB
maxrand_1 AC 1 ms 2028 KB
maxrand_2 AC 2 ms 2148 KB
maxrand_3 AC 1 ms 2080 KB
maxrand_4 AC 1 ms 2164 KB
rand_0 AC 1 ms 2064 KB
rand_1 AC 2 ms 2148 KB
rand_2 AC 2 ms 2076 KB


2025-04-08 (Tue)
04:14:27 +00:00