Submission #19271026


Source Code Expand

Copy
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [u64; n],
    };
    let mut count = 1;
    let mut p = a[0];
    let mut d = None;
    for a_i in a {
        if p == a_i {
            continue;
        }
        match d {
            None => {
                if p < a_i {
                    d = Some(true);
                } else if p > a_i {
                    d = Some(false);
                }
            }
            Some(true) => {
                if p > a_i {
                    d = None;
                    count += 1;
                }
            }
            Some(false) => {
                if p < a_i {
                    d = None;
                    count += 1;
                }
            }
        }
        p = a_i;
    }
    let ans = count;
    println!("{}", ans);
}

Submission Info

Submission Time
Task A - Sorted Arrays
User bouzuya
Language Rust (1.42.0)
Score 300
Code Size 827 Byte
Status AC
Exec Time 19 ms
Memory 3684 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 17
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt
Case Name Status Exec Time Memory
sample_01.txt AC 9 ms 2004 KB
sample_02.txt AC 2 ms 2004 KB
sample_03.txt AC 1 ms 2088 KB
subtask_1_01.txt AC 11 ms 3028 KB
subtask_1_02.txt AC 7 ms 2832 KB
subtask_1_03.txt AC 4 ms 2436 KB
subtask_1_04.txt AC 11 ms 3536 KB
subtask_1_05.txt AC 10 ms 3528 KB
subtask_1_06.txt AC 19 ms 3628 KB
subtask_1_07.txt AC 10 ms 3684 KB
subtask_1_08.txt AC 14 ms 3616 KB
subtask_1_09.txt AC 11 ms 3580 KB
subtask_1_10.txt AC 2 ms 2112 KB
subtask_1_11.txt AC 1 ms 2032 KB