結果

問題 No.269 見栄っ張りの募金活動
コンテスト
ユーザー とくまるpro
提出日時 2022-12-03 17:00:31
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 1,104 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 8,601 ms
コンパイル使用メモリ 191,420 KB
実行使用メモリ 18,176 KB
最終ジャッジ日時 2026-04-26 22:37:14
合計ジャッジ時間 9,781 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unnecessary parentheses around `for` iterator expression
  --> src/main.rs:34:14
   |
34 |     for i in (1..=N) {
   |              ^     ^
   |
   = note: `#[warn(unused_parens)]` (part of `#[warn(unused)]`) on by default
help: remove these parentheses
   |
34 -     for i in (1..=N) {
34 +     for i in 1..=N {
   |

warning: unnecessary parentheses around `for` iterator expression
  --> src/main.rs:35:18
   |
35 |         for j in (0..=(S as usize)) {
   |                  ^                ^
   |
help: remove these parentheses
   |
35 -         for j in (0..=(S as usize)) {
35 +         for j in 0..=(S as usize) {
   |

warning: constant `DXY` is never used
  --> src/main.rs:15:7
   |
15 | const DXY: [(isize, isize); 4] = [(0, 1), (0, -1), (1, 0), (-1, 0)];
   |       ^^^
   |
   = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

warning: constant `FIRST_VALUE` is never used
  --> src/main.rs:16:7
   |
16 | const FIRST_VALUE: usize = 1_000_000_000;
   |       ^^^^^^^^^^^

ソースコード

diff #
raw source code

#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use proconio::{
    input,
    marker::{Chars, Isize1, Usize1},
};
#[allow(unused_imports)]
use std::{
    cmp::Reverse,
    cmp::{max, min},
    collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, VecDeque},
    process::exit,
};
const DXY: [(isize, isize); 4] = [(0, 1), (0, -1), (1, 0), (-1, 0)];
const FIRST_VALUE: usize = 1_000_000_000;
const MOD: usize = 1_000_000_007;
#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        mut S: isize,
        K: usize,
    }
    S -= (K * N * (N - 1) / 2) as isize;
    if S < 0 {
        println!("0");
        exit(0);
    }

    let mut dp = vec![vec![0; S as usize + 1]; N + 1];
    // dp[i][j] := jをi分割するときの総数
    dp[0][0] = 1;
    for i in (1..=N) {
        for j in (0..=(S as usize)) {
            if j >= i {
                dp[i][j] = dp[i - 1][j] + dp[i][j - i];
                dp[i][j] %= MOD;
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    println!("{}", dp[N][S as usize]);
}
0