結果

問題 No.2008 Super Worker
ユーザー phsplsphspls
提出日時 2022-09-06 13:17:23
言語 Rust
(1.77.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 1,167 bytes
コンパイル時間 14,099 ms
コンパイル使用メモリ 378,784 KB
実行使用メモリ 12,272 KB
最終ジャッジ日時 2024-05-01 10:48:57
合計ジャッジ時間 15,148 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 1 ms
5,248 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 0 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 0 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 76 ms
11,008 KB
testcase_24 AC 76 ms
10,928 KB
testcase_25 AC 75 ms
11,008 KB
testcase_26 AC 73 ms
11,088 KB
testcase_27 AC 74 ms
11,008 KB
testcase_28 AC 80 ms
12,160 KB
testcase_29 AC 80 ms
12,128 KB
testcase_30 AC 82 ms
12,272 KB
testcase_31 AC 82 ms
12,160 KB
testcase_32 AC 81 ms
12,160 KB
testcase_33 AC 24 ms
11,392 KB
testcase_34 AC 83 ms
12,220 KB
testcase_35 AC 18 ms
9,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::cmp::Reverse;


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

#[derive(PartialEq, PartialOrd, Clone, Debug)]
struct Sortable<T>(T);
 
impl<T: PartialEq> Eq for Sortable<T> {}
impl<T: PartialOrd> Ord for Sortable<T> {
    fn cmp(&self, other: &Sortable<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

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 pairs = (0..n).map(|i| (a[i], b[i])).collect::<Vec<(usize, usize)>>();
    pairs.sort_by_key(|&(a, b)| Reverse(Sortable((b - 1) as f64 / a as f64)));
    let mut level = 1usize;
    let mut result = 0usize;
    for &(a, b) in pairs.iter() {
        result += level * a % MOD;
        level = level * b % MOD;
    }
    println!("{}", result % MOD);
}
0