結果
| 問題 |
No.1144 Triangles
|
| コンテスト | |
| ユーザー |
akakimidori
|
| 提出日時 | 2021-04-16 18:36:33 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 129 ms / 3,000 ms |
| コード長 | 990 bytes |
| コンパイル時間 | 16,877 ms |
| コンパイル使用メモリ | 378,552 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-02 18:53:58 |
| 合計ジャッジ時間 | 18,627 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 25 |
ソースコード
fn read() -> Vec<(i64, i64)> {
let mut s = String::new();
use std::io::Read;
std::io::stdin().read_to_string(&mut s).unwrap();
let mut it = s.trim().split_whitespace();
let mut next = || it.next().unwrap().parse::<i64>().unwrap();
let n = next();
(0..n)
.map(|_| {
let x = next();
let y = next();
(x, y)
})
.collect()
}
fn main() {
let mut p = read();
p.sort_by_key(|p| (p.1, p.0));
const MOD: i64 = 1_000_000_007;
let mut ans = 0;
for i in 0..(p.len() - 2) {
let s = p[i];
let mut p = p[(i + 1)..]
.iter()
.map(|p| (p.0 - s.0, p.1 - s.1))
.collect::<Vec<_>>();
p.sort_by(|a, b| (a.0 * b.1).cmp(&(a.1 * b.0)));
let mut a = 0;
let mut b = 0;
for &(x, y) in p.iter() {
ans = (ans + b * x - a * y) % MOD;
a += x;
b += y;
}
}
println!("{}", ans);
}
akakimidori