結果

問題 No.281 門松と魔法(1)
ユーザー chakkuchakku
提出日時 2016-11-05 18:20:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,739 bytes
コンパイル時間 1,484 ms
コンパイル使用メモリ 166,200 KB
実行使用メモリ 5,328 KB
最終ジャッジ日時 2023-08-16 13:54:27
合計ジャッジ時間 5,267 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }

constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll d;
    vector<ll> h(3);
    cin>>d;
    rep(i,3) cin>>h[i];

    if(h[0]==0 and h[1] == 0 and h[2]==0){
        cout << -1 << endl;
        return 0;
    }

    ll ans=0;
    if(h[0]==h[2]){
        ans++;
        h[2]-=d;
    }
    if(h[0]!=h[1] and h[1]!=h[2]){
        if(h[0]>h[1] and h[2]>h[1]){
            cout << ans << endl;
            return 0;
        }else if(h[0] > h[1] and h[1] > h[2]){
            cout << ans << endl;
            return 0;
        }
    }

    if(h[0] > h[2]) swap(h[0],h[2]);

    ll m = h[0]-1;
    ll d1 = ((h[1]-m)+d-1)/d;

    ll m2=h[1]-1;
    ll d2 = ((h[2]-m2)+d-1)/d;
    debug(h);
    debug2(d1,d2);
    cout << min(d1,d2)+ans << endl;
}
0