0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

初心者プログラマーがAtCoderに挑んだ軌跡-ABC408-A-

Posted at

ABC408-A

問題の内容

タイムアウト判定
行動間隔が一定時間以上空いていないか

言語

Rust

解法

配列で与えられた時間の差がタイムアウト時間を超えていないか調べる

課題

  • t[i]-t[i-1]の形にしたとき1..nで回すとt[0]が考慮できていない
  • 処理が重くならないようにbreak処理を入れるべき

学んだこと

  • for などで回すiはusizeじゃないといけない
    コンパイルエラーが出た

提出内容

fn main() {
  input! {
    n: usize,
    s: i64,
    t: [i64;n],
  }
  let mut flag = true;
  if t[0] > s {flag = false;}
  for i in 1..n {
    if t[i] - t[i - 1] > s {
      flag = false;
      break;
    }
  }
  if flag {
    println!("Yes");
  } else {
    println!("No");
  }
}

成績

  • 324Byte
  • AC
  • 1ms
  • 2100KiB
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?