結果
| 問題 |
No.281 門松と魔法(1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-09-20 20:55:41 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,133 bytes |
| コンパイル時間 | 700 ms |
| コンパイル使用メモリ | 86,628 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-06 19:40:21 |
| 合計ジャッジ時間 | 2,329 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 49 WA * 6 RE * 2 |
ソースコード
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;
int f(int d, int h1, int h2, int h3) {
assert (h1 != h3);
if (h1 < h3) {
swap(h1, h3);
}
if (h3 < 0) { return -1; }
if (h2 > h1 || h2 < h3) {
return 0;
}
if (h3 == 0) { return -1; }
int sub1 = (h2 - h3 + 1 + d - 1) / d;
int sub2 = (h1 - h2 + d) / d;
if (h1 - sub2 * d == h3) { sub2++; }
return min(sub1, sub2);
}
int main(void){
int d, h1, h2, h3;
cin >> d >> h1 >> h2 >> h3;
if (h1 == h3) {
int r = f(d, h1, h2, h3 - d);
cout << (r < 0 ? -1 : r + 1) << endl;
return 0;
}
cout << f(d, h1, h2, h3) << endl;
}