結果
問題 | No.1623 三角形の制作 |
ユーザー | phspls |
提出日時 | 2022-10-25 00:09:54 |
言語 | Rust (1.77.0) |
結果 |
AC
|
実行時間 | 341 ms / 2,000 ms |
コード長 | 1,609 bytes |
コンパイル時間 | 670 ms |
コンパイル使用メモリ | 147,912 KB |
実行使用メモリ | 150,396 KB |
最終ジャッジ日時 | 2023-09-16 01:30:00 |
合計ジャッジ時間 | 9,239 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 313 ms
142,860 KB |
testcase_01 | AC | 312 ms
142,868 KB |
testcase_02 | AC | 330 ms
146,984 KB |
testcase_03 | AC | 330 ms
146,784 KB |
testcase_04 | AC | 335 ms
146,756 KB |
testcase_05 | AC | 341 ms
150,176 KB |
testcase_06 | AC | 319 ms
143,816 KB |
testcase_07 | AC | 332 ms
146,836 KB |
testcase_08 | AC | 323 ms
144,108 KB |
testcase_09 | AC | 335 ms
146,636 KB |
testcase_10 | AC | 333 ms
148,916 KB |
testcase_11 | AC | 328 ms
147,616 KB |
testcase_12 | AC | 331 ms
145,168 KB |
testcase_13 | AC | 330 ms
145,640 KB |
testcase_14 | AC | 318 ms
145,548 KB |
testcase_15 | AC | 333 ms
149,836 KB |
testcase_16 | AC | 338 ms
149,864 KB |
testcase_17 | AC | 334 ms
149,856 KB |
testcase_18 | AC | 336 ms
150,396 KB |
testcase_19 | AC | 323 ms
146,076 KB |
testcase_20 | AC | 311 ms
142,876 KB |
コンパイルメッセージ
warning: unused variable: `n` --> Main.rs:7:9 | 7 | let n: usize = n.trim().parse().unwrap(); | ^ help: if this is intentional, prefix it with an underscore: `_n` | = note: `#[warn(unused_variables)]` on by default warning: 1 warning emitted
ソースコード
const MAXVAL: usize = 3000; fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); let mut r = String::new(); std::io::stdin().read_line(&mut r).ok(); let r: Vec<usize> = r.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let mut g = String::new(); std::io::stdin().read_line(&mut g).ok(); let g: Vec<usize> = g.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 gcnts = vec![0usize; MAXVAL+1]; let mut bcnts = vec![0usize; MAXVAL+1]; let mut sum2max = vec![vec![0usize; MAXVAL+1]; 2*MAXVAL+1]; for &v in g.iter() { gcnts[v] += 1; } for &v in b.iter() { bcnts[v] += 1; } for i in 0..=MAXVAL { for j in 0..=MAXVAL { sum2max[i+j][i.max(j)] += gcnts[i] * bcnts[j]; } } for sumval in 0..=2*MAXVAL { for maxval in 0..=MAXVAL { if sumval > 0 { sum2max[sumval][maxval] += sum2max[sumval-1][maxval]; } if maxval > 0 { sum2max[sumval][maxval] += sum2max[sumval][maxval-1]; } if sumval > 0 && maxval > 0 { sum2max[sumval][maxval] -= sum2max[sumval-1][maxval-1]; } } } let mut result = 0usize; for &v in r.iter() { result += sum2max[2*v][v] - sum2max[v][v]; } println!("{}", result); }