Submission #1689167


Source Code Expand

fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

fn solve(s: i64, c: i64) -> i64 {
    if c <= 1 {
        return 0;
    }

    if s * 2 >= c {
        return c/2;
    }


    // s*2 < c の場合
    // s個は絶対作る。残りのパーツでできるだけsccを作る
    let ans = s + (c - s * 2) / 4;
    return ans;
}

fn main() {
    let s = getline();
    let vec: Vec<i64> = s.trim().split(' ').map(|s| s.parse().unwrap()).collect();
    let s = vec[0];
    let c = vec[1];

    let ans = solve(s, c);
    println!("{}", ans);
}

Submission Info

Submission Time
Task C - Scc Puzzle
User sakaki
Language Rust (1.15.1)
Score 300
Code Size 654 Byte
Status AC
Exec Time 2 ms
Memory 4352 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 9
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt
All 00_example_01.txt, 00_example_02.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 2 ms 4352 KB
00_example_02.txt AC 2 ms 4352 KB
01.txt AC 2 ms 4352 KB
02.txt AC 2 ms 4352 KB
03.txt AC 2 ms 4352 KB
04.txt AC 2 ms 4352 KB
05.txt AC 2 ms 4352 KB
06.txt AC 2 ms 4352 KB
07.txt AC 2 ms 4352 KB