結果

問題 No.281 門松と魔法(1)
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2015-09-19 00:22:46
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,456 bytes
コンパイル時間 694 ms
コンパイル使用メモリ 92,224 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-24 11:44:56
合計ジャッジ時間 1,956 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cassert>
#include <iostream>
#include <stdio.h>
#include <time.h>
 
using namespace std;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
 
#define MOD 1000000007

int check(int a, int b, int c){
  if(a==b||a==c||b==c)return 0;
  vector<int> v;
  v.pb(a);v.pb(b);v.pb(c);
  sort(all(v));
  if(b==v[1])return 0;
  return 1;
}

int main(){
  int d;
  cin>>d;
  int h1,h2,h3;
  cin>>h1>>h2>>h3;
  int ans = 2000000000;
  if(check(h1,h2,h3)){
    cout << ans << endl;
    return 0;
  }
  else if(d==0){
    cout << -1 << endl;
    return 0;
  }
  rep(i,0,3){
    rep(j,0,3){
      rep(k,0,3){
        int a = max(0,h1-d*i);
        int b = max(0,h2-d*j);
        int c = max(0,h3-d*k);
        if(check(a,b,c)){
          ans = min(ans,i+j+k);
        }
      }
    }
  }
  int mn = min(h1,h3);
  if(mn==0||((h1<2)&&(h3<2))){
    cout << -1 << endl;
  }
  cout << min(ans, (h2-mn)/d+1) << endl;
  return 0;
}
0