結果

問題 No.909 たぴの配置
ユーザー phsplsphspls
提出日時 2020-01-27 23:50:14
言語 Rust
(1.77.0)
結果
AC  
実行時間 270 ms / 3,000 ms
コード長 1,056 bytes
コンパイル時間 4,516 ms
コンパイル使用メモリ 151,748 KB
実行使用メモリ 9,288 KB
最終ジャッジ日時 2023-10-12 18:05:36
合計ジャッジ時間 10,071 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 256 ms
8,972 KB
testcase_06 AC 263 ms
9,276 KB
testcase_07 AC 243 ms
8,904 KB
testcase_08 AC 258 ms
8,868 KB
testcase_09 AC 270 ms
9,220 KB
testcase_10 AC 252 ms
8,800 KB
testcase_11 AC 244 ms
8,856 KB
testcase_12 AC 262 ms
8,956 KB
testcase_13 AC 265 ms
9,288 KB
testcase_14 AC 242 ms
8,892 KB
testcase_15 AC 241 ms
8,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Read;
use std::cmp::{max, min};

fn main() {
    let mut all_data = String::new();
    std::io::stdin().read_to_string(&mut all_data).ok();
    let all_data: Vec<&str> = all_data.trim().split('\n').map(|i| i.trim()).collect();
    let n: usize = all_data.iter().next().unwrap().parse::<usize>().unwrap();
    let x: Vec<usize> = all_data.iter().skip(1).next().unwrap().split_whitespace().map(|i| i.parse::<usize>().unwrap()).collect();
    let y: Vec<usize> = all_data.iter().skip(2).next().unwrap().split_whitespace().map(|i| i.parse::<usize>().unwrap()).collect();
    let minidx2val: (usize, usize) = x.iter().zip(y.iter()).map(|pair| pair.0 + pair.1).enumerate().min_by_key(|pair| pair.1).unwrap();
    println!("{}", minidx2val.1);
    for i in 0..(n+2) {
        if i == 0 {
            println!("{}", 0);
        } else if i == n+1 {
            println!("{}", minidx2val.1);
        } else {
            println!("{}", max(if minidx2val.1 < y[i-1] { 0 } else { minidx2val.1 - y[i-1] }, min(x[i-1], x[minidx2val.0])));
        }
    }
}
0