結果

問題 No.188 HAPPY DAY
ユーザー YoshihitoYoshihito
提出日時 2020-07-16 19:45:28
言語 Rust
(1.72.1)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 1,020 bytes
コンパイル時間 925 ms
コンパイル使用メモリ 131,448 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-08-16 15:28:27
合計ジャッジ時間 1,387 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::{self};
use std::cmp;

#[derive(Debug)]
struct Input {
}

fn read_input(_cin_lock: &mut io::StdinLock) -> Input {
    Input {}
}

fn solve(_input: Input, _cin_lock: &mut io::StdinLock) {
    let answer = num_happy_days();
    println!("{}", answer);
}

fn num_happy_days() -> usize {
    let days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

    let mut happy_days = 0;

    // 1月 -9月
    for m in 1..10 {
        let last_day = days[m - 1];
        let upper_limit = cmp::min(last_day / 10, m);

        happy_days += upper_limit;
        let lower = m - upper_limit;
        if upper_limit * 10 + lower <= last_day {
            happy_days += 1;
        }
    }

    // 10月 - 12月
    for m in 10..=12 {
        happy_days += if m - 1 < 10 { 1 } else { 0 };
        happy_days += if m - 2 < 10 { 1 } else { 0 };
    }

    happy_days
}

fn main() {
    let cin = io::stdin();
    let mut cin_lock = cin.lock();

    let input = read_input(&mut cin_lock);
    solve(input, &mut cin_lock);
}
0