結果
| 問題 |
No.281 門松と魔法(1)
|
| コンテスト | |
| ユーザー |
xuzijian629
|
| 提出日時 | 2018-10-31 07:05:48 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 794 bytes |
| コンパイル時間 | 1,658 ms |
| コンパイル使用メモリ | 193,124 KB |
| 最終ジャッジ日時 | 2025-01-06 15:10:58 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 42 WA * 15 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;
int main() {
int d;
int a, b, c;
cin >> d >> a >> b >> c;
if (a < b && b > c) {
cout << 0 << endl;
return 0;
}
if (a > b && b < c) {
cout << 0 << endl;
return 0;
}
if (d == 0 || b == 0) {
cout << -1 << endl;
return 0;
}
int ans = -1;
int k = min(a, c);
if (k != 0) {
int diff = b - (k - 1);
ans = (diff + d - 1) / d;
}
k = max(a, c);
if (k != 0) {
int diff = k - (b - 1);
if (ans == -1) {
ans = (diff + d - 1) / d;
} else {
ans = min(ans, (diff + d - 1) / d);
}
}
cout << ans << endl;
}
xuzijian629