結果

問題 No.2008 Super Worker
ユーザー phsplsphspls
提出日時 2022-09-13 11:20:00
言語 Rust
(1.77.0)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 1,030 bytes
コンパイル時間 1,261 ms
コンパイル使用メモリ 139,220 KB
実行使用メモリ 10,096 KB
最終ジャッジ日時 2023-08-20 12:45:48
合計ジャッジ時間 5,478 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,384 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 AC 1 ms
4,384 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,384 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,384 KB
testcase_21 AC 1 ms
4,384 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 62 ms
8,880 KB
testcase_24 AC 62 ms
8,872 KB
testcase_25 AC 62 ms
8,868 KB
testcase_26 AC 62 ms
8,880 KB
testcase_27 AC 63 ms
8,800 KB
testcase_28 AC 66 ms
10,048 KB
testcase_29 AC 67 ms
10,052 KB
testcase_30 AC 67 ms
10,040 KB
testcase_31 AC 66 ms
10,044 KB
testcase_32 AC 66 ms
9,984 KB
testcase_33 AC 22 ms
9,864 KB
testcase_34 AC 65 ms
10,096 KB
testcase_35 AC 16 ms
8,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::cmp::Ordering;

const MOD: usize = 1e9 as usize + 7;

fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();
    let mut a = String::new();
    std::io::stdin().read_line(&mut a).ok();
    let a: Vec<usize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let mut b = String::new();
    std::io::stdin().read_line(&mut b).ok();
    let b: Vec<usize> = b.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mut orders = (0..n).collect::<Vec<usize>>();
    orders.sort_by(|&i, &j| {
        let lr = a[i] + b[i] * a[j];
        let rl = a[j] + b[j] * a[i];
        if lr > rl {
            Ordering::Less
        } else {
            Ordering::Greater
        }
    });
    let mut result = 0usize;
    let mut level = 1usize;
    for &i in orders.iter() {
        result += level * a[i] % MOD;
        result %= MOD;
        level *= b[i];
        level %= MOD;
    }
    println!("{}", result);
}
0