結果

問題 No.281 門松と魔法(1)
ユーザー alpha_virginisalpha_virginis
提出日時 2015-09-18 23:08:27
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,381 bytes
コンパイル時間 1,266 ms
コンパイル使用メモリ 157,728 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 11:24:38
合計ジャッジ時間 2,718 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 WA -
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 WA -
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 WA -
testcase_39 AC 1 ms
5,376 KB
testcase_40 AC 1 ms
5,376 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 1 ms
5,376 KB
testcase_45 AC 1 ms
5,376 KB
testcase_46 AC 1 ms
5,376 KB
testcase_47 AC 1 ms
5,376 KB
testcase_48 AC 2 ms
5,376 KB
testcase_49 AC 1 ms
5,376 KB
testcase_50 AC 1 ms
5,376 KB
testcase_51 WA -
testcase_52 AC 1 ms
5,376 KB
testcase_53 AC 2 ms
5,376 KB
testcase_54 WA -
testcase_55 AC 1 ms
5,376 KB
testcase_56 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <cstdint>
#include <sys/time.h>

typedef std::int_fast32_t  s32;
typedef std::uint_fast32_t u32;
typedef std::int_fast64_t  s64;
typedef std::uint_fast64_t u64;

const unsigned long mod = 1000000007;
const double EPS = 0.00000001;
const int INF = (1 << 29);

typedef std::pair<int, int> P;

template<typename T>
void print_array(T *A_, s32 size) {
  printf("%d\n", size);
  if( size != 0 ) {
    for(int i = 0; i < size - 1; ++i) {
      printf("%d ", A_[i]);
    }
    printf("%d\n", A_[size - 1]);
  }
}

int d;
int a, b, c;

int p1(void) {
  if( a == 0 or c == 0 ) return INF;
  if( a < b and c < b ) return 0;
  if( a > b and c > b ) return 0;
  if( a == b ) return INF;
  if( d == 0 ) return INF;
  return (b - std::min(a, c)) / d + 1;
}

int p2(void) {
  if( b == 0 ) return INF;
  if( a < b and c < b ) return 0;
  if( d == 0 ) return INF;
  int res = 0;
  if( c >= b ) {
    res += (c - b) / d + 1;
  }
  if( a >= b ) {
    res += (a - b) / d + 1;
  }
  if( a == c ) {
    res += 1;
    if( (b - ((a - b) / d + 1) * d) <= 0 ) {
      res = INF;
    }
  }
  return res;
}


int main() {


  std::cin >> d;
  std::cin >> a >> b >> c;

  int res = INF;

  res = std::min(res, p1());
  res = std::min(res, p2());

  if( res == INF ) res = -1;
  std::cout << res << std::endl;

  std::cerr << p1() << " " << p2() << std::endl;
  
  return 0;
}
0