結果
| 問題 | No.3557 KCPC or KUPC 2 |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2026-05-30 06:35:29 |
| 言語 | Rust (1.94.0 + proconio + num + itertools) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 1,576 bytes |
| 記録 | |
| コンパイル時間 | 1,102 ms |
| コンパイル使用メモリ | 199,084 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-30 06:35:37 |
| 合計ジャッジ時間 | 5,704 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_0 |
| 純コード判定待ち |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| 部分点1 | 10 % | AC * 30 |
| 部分点2 | 40 % | AC * 30 |
| 部分点3 | 50 % | AC * 30 |
| 合計 | 100 点 |
コンパイルメッセージ
warning: constant `INF` is never used --> src/main.rs:45:7 | 45 | const INF: i128 = 1 << 60; | ^^^ | = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default
ソースコード
#![allow(non_snake_case, unused_imports)]
use proconio::{input, marker::Usize1, marker::Chars};
use itertools::Itertools;
#[allow(unused_macros)]
macro_rules! d {
( $( $x:expr ),* $(,)? ) => {
eprintln!(
concat!( $( stringify!($x), "={:?} " ),* ),
$( $x ),*
);
};
}
#[allow(dead_code)]
fn yn(b: bool) -> &'static str {
if b { "Yes" } else { "No" }
}
fn divmod(a: i128, b: i128) -> (i128, i128) {
(a.div_euclid(b), a.rem_euclid(b))
}
fn bsearch_right<F>(low: i128, high: i128, pred: F) -> i128
where
F: Fn(i128) -> bool,
{
let mut lo = low;
let mut hi = high;
let mut res = hi;
while lo <= hi {
let m = (lo + hi) / 2;
if pred(m) {
res = res.min(m);
hi = m - 1;
} else {
lo = m + 1;
}
}
res
}
const INF: i128 = 1 << 60;
fn main() {
input! {
N: i128,
A: i128, B: i128, C: i128,
D: i128, E: i128, F: i128,
}
let income = |n: i128, a: i128, b: i128, c: i128| -> i128 {
// 0 0 ... 0 (b 個)
// c c ... c
// 2c 2c ... 2c
let (d, m) = divmod(n, b);
let last = (d-1) * c;
let s = (0 + last) * d / 2;
let res = n * a + s * b + (d * c * m);
res
};
let x = bsearch_right(0, N, |m| income(m, A, B, C) >= N);
let y = bsearch_right(0, N, |m| income(m, D, E, F) >= N);
let ans = if x == y {
"Same"
} else if x < y {
"KCPC"
} else {
"KUPC"
};
println!("{}", ans);
}
norioc