結果
問題 | No.1233 割り切れない気持ち |
ユーザー | tzyvrn |
提出日時 | 2020-09-19 16:22:19 |
言語 | Rust (1.77.0) |
結果 |
AC
|
実行時間 | 41 ms / 3,153 ms |
コード長 | 1,713 bytes |
コンパイル時間 | 3,630 ms |
コンパイル使用メモリ | 162,668 KB |
実行使用メモリ | 14,536 KB |
最終ジャッジ日時 | 2023-09-05 21:45:52 |
合計ジャッジ時間 | 6,858 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
4,408 KB |
testcase_01 | AC | 3 ms
4,428 KB |
testcase_02 | AC | 7 ms
4,420 KB |
testcase_03 | AC | 8 ms
4,444 KB |
testcase_04 | AC | 8 ms
4,436 KB |
testcase_05 | AC | 7 ms
4,396 KB |
testcase_06 | AC | 7 ms
4,424 KB |
testcase_07 | AC | 18 ms
6,864 KB |
testcase_08 | AC | 21 ms
7,556 KB |
testcase_09 | AC | 32 ms
9,824 KB |
testcase_10 | AC | 31 ms
9,856 KB |
testcase_11 | AC | 17 ms
6,816 KB |
testcase_12 | AC | 41 ms
14,528 KB |
testcase_13 | AC | 40 ms
14,496 KB |
testcase_14 | AC | 40 ms
14,520 KB |
testcase_15 | AC | 41 ms
14,536 KB |
testcase_16 | AC | 41 ms
14,476 KB |
testcase_17 | AC | 13 ms
6,404 KB |
testcase_18 | AC | 41 ms
14,504 KB |
testcase_19 | AC | 17 ms
8,920 KB |
testcase_20 | AC | 13 ms
6,436 KB |
testcase_21 | AC | 15 ms
6,436 KB |
testcase_22 | AC | 15 ms
6,408 KB |
testcase_23 | AC | 15 ms
6,372 KB |
testcase_24 | AC | 14 ms
6,356 KB |
testcase_25 | AC | 14 ms
6,372 KB |
testcase_26 | AC | 15 ms
6,440 KB |
testcase_27 | AC | 16 ms
7,132 KB |
testcase_28 | AC | 15 ms
7,072 KB |
testcase_29 | AC | 15 ms
6,948 KB |
testcase_30 | AC | 16 ms
7,000 KB |
testcase_31 | AC | 16 ms
6,920 KB |
testcase_32 | AC | 15 ms
6,952 KB |
testcase_33 | AC | 16 ms
8,552 KB |
testcase_34 | AC | 16 ms
6,844 KB |
testcase_35 | AC | 16 ms
6,856 KB |
testcase_36 | AC | 16 ms
6,836 KB |
testcase_37 | AC | 4 ms
4,376 KB |
testcase_38 | AC | 13 ms
6,408 KB |
testcase_39 | AC | 28 ms
10,132 KB |
testcase_40 | AC | 29 ms
10,132 KB |
コンパイルメッセージ
warning: unused import: `HashSet` --> Main.rs:1:33 | 1 | use std::collections::{HashMap, HashSet}; | ^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: use of deprecated associated function `core::str::<impl str>::trim_right`: superseded by `trim_end` --> Main.rs:10:23 | 10 | let s = s.trim_right(); | ^^^^^^^^^^ ... 33 | let n = getl!(usize); | ------------ in this macro invocation | = note: `#[warn(deprecated)]` on by default = note: this warning originates in the macro `getl` (in Nightly builds, run with -Z macro-backtrace for more info) help: replace the use of the deprecated associated function | 10 | let s = s.trim_end(); | ~~~~~~~~ warning: use of deprecated associated function `core::str::<impl str>::trim_right`: superseded by `trim_end` --> Main.rs:22:19 | 22 | let s = s.trim_right(); | ^^^^^^^^^^ ... 34 | let mut a = getl_vec!(usize); | ---------------- in this macro invocation | = note: this warning originates in the macro `getl_vec` (in Nightly builds, run with -Z macro-backtrace for more info) help: replace the use of the deprecated associated function | 22 | let s = s.trim_end(); | ~~~~~~~~ warning: variable does not need to be mutable --> Main.rs:34:9 | 34 | let mut a = getl_vec!(usize); | ----^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by default warning: 4 warnings emitted
ソースコード
use std::collections::{HashMap, HashSet}; //{{{ #[allow(unused_macros)] macro_rules! getl { ( $( $t:ty ),* ) => { { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); let s = s.trim_right(); let mut ws = s.split_whitespace(); ($(ws.next().unwrap().parse::<$t>().unwrap()),*) } }; } #[allow(unused_macros)] macro_rules! getl_vec { ( $t:ty ) => {{ let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); let s = s.trim_right(); s.split_whitespace() .map(|x| x.parse().unwrap()) .collect::<Vec<$t>>() }}; } //}}} const MAX: usize = 300_000; fn main() { let n = getl!(usize); let mut a = getl_vec!(usize); let mut c = vec![0usize; MAX]; for a_i in a.iter().copied() { c[a_i] += 1; } let mut sc = vec![0usize]; for c_i in c { let last = sc.last().copied().unwrap(); sc.push(c_i + last); } let sc = sc; let mut map = HashMap::new(); for a_i in a.iter().copied() { let entry = map.entry(a_i).or_insert(0usize); *entry += 1; } let s: usize = a.iter().sum(); let mut ans = 0usize; for (a_i, c_i) in map { let mut now = s * c_i; let mut m = 0; while a_i * m < MAX { // dbg!(now, c_i, m, a_i, &sc[..=10]); if (m + 1) * a_i <= MAX { now -= c_i * m * a_i * (sc[(m + 1) * a_i] - sc[m * a_i]); } else { now -= c_i * m * a_i * (n - sc[m * a_i]); } m += 1; } ans += now; } println!("{}", ans); }