結果
| 問題 |
No.281 門松と魔法(1)
|
| コンテスト | |
| ユーザー |
h_noson
|
| 提出日時 | 2016-03-15 23:05:12 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,998 bytes |
| コンパイル時間 | 649 ms |
| コンパイル使用メモリ | 61,312 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-06 19:50:50 |
| 合計ジャッジ時間 | 2,290 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 43 WA * 12 RE * 2 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1e8
typedef long long ll;
int main() {
int d, h1, h2, h3;
cin >> d >> h1 >> h2 >> h3;
if (h1 > h3)
swap(h1,h3);
if (h1 == 0 && h2 == 0 || h3 == 0)
cout << -1 << endl;
else if (h1 == h2 && h2 == h3) {
if (h1 > d)
cout << 2 << endl;
else
cout << -1 << endl;
}
else if (h1 == h3) {
if (h1 < h2)
cout << 1 << endl;
else if (h1 < d)
cout << -1 << endl;
else if (h1 - d == h2) {
if (h1 < 2*d)
cout << -1 << endl;
else
cout << 2 << endl;
}
else
cout << 1 << endl;
}
else if (h1 == h2) {
if (h1 >= d)
cout << 1 << endl;
else
cout << -1 << endl;
}
else if (h2 == h3) {
if (h1 == h3 - d) {
if (h3 > 2*d)
cout << 2 << endl;
else
cout << -1 << endl;
}
else if (h3 >= d)
cout << 1 << endl;
else
cout << -1 << endl;
}
else if ((h2 < h1 || h2 > h3))
cout << 0 << endl;
else {
int x, y;
x = y = 1e9;
if (h2 - ((h2-h1)/d+1)*d >= 0) {
if (h1 != h2 - ((h2-h1)/d+1)*d)
x = (h2-h1)/d+1;
else if (h2 - ((h2-h1)/d+2)*d >= 0)
x = (h2-h1)/d+2;
}
if (h3 - ((h3-h2)/d+1)*d >= 0) {
if (h2 != h3 - ((h3-h2)/d+1)*d)
y = (h3-h2)/d+1;
else if (h3 - ((h3-h2)/d+2)*d >= 0)
y = (h3-h2)/d+2;
}
if (min(x,y) == 1e9)
cout << -1 << endl;
else
cout << min(x,y) << endl;
}
return 0;
}
h_noson