結果

問題 No.281 門松と魔法(1)
ユーザー maine_honzuki
提出日時 2021-05-12 10:52:59
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 574 bytes
コンパイル時間 2,011 ms
コンパイル使用メモリ 194,396 KB
最終ジャッジ日時 2025-01-21 10:15:11
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 39 WA * 14 RE * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

//https://ncode.syosetu.com/n4830bu/281/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ll d;
    vector<ll> H(3);
    cin >> d;
    for (auto&& h : H) {
        cin >> h;
    }
    auto book = [&](ll height, ll threshold) {
        if (threshold == 0)
            return (ll)1e11;
        if (height < threshold)
            return 0ll;
        return (height - threshold + d) / d;
    };
    ll maine = min(book(H[0], H[1]) + book(H[2], H[1]), book(H[1], H[0]) + book(H[1], H[2]));
    cout << (maine > 1e10 ? -1 : maine) << endl;
}
0