結果

問題 No.33 アメーバがたくさん
コンテスト
ユーザー tonyu0
提出日時 2019-12-24 23:51:00
言語 Rust
(1.97.1 + proconio + num + itertools + ACL)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 0 ms / 5,000 ms
+ 850µs
コード長 1,202 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 11,712 ms
コンパイル使用メモリ 193,236 KB
実行使用メモリ 9,796 KB
最終ジャッジ日時 2026-09-02 14:45:55
合計ジャッジ時間 13,256 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use std::io::Read;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let d: i64 = itr.next().unwrap().parse().unwrap();
    let t: i64 = itr.next().unwrap().parse().unwrap();
    let mut a: Vec<i64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    a.sort();
    let mut ans: i64 = 0;
    let mut check: Vec<bool> = vec![false; n];
    for i in 0..n {
        if !check[i] {
            check[i] = true;
            // 左側
            ans += t * 2 + 1;
            let mut l: usize = i;
            let mut r: usize = i + 1;
            while r < n {
                if (a[r] - a[l]).abs() % d != 0 {
                    r += 1;
                    continue;
                }
                check[r] = true;
                if (a[r] - a[l]).abs() / 2 <= t * d {
                    ans += (a[r] - a[l]).abs() / d;
                } else {
                    ans += t * 2 + 1;
                }
                l = r;
                r += 1;
            }
        }
    }
    println!("{}", ans);
}
0