結果
| 問題 |
No.281 門松と魔法(1)
|
| コンテスト | |
| ユーザー |
nmnmnmnmnmnmnm
|
| 提出日時 | 2015-09-19 00:22:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,456 bytes |
| コンパイル時間 | 796 ms |
| コンパイル使用メモリ | 91,784 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-06 19:32:33 |
| 合計ジャッジ時間 | 2,275 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 28 WA * 29 |
ソースコード
#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;
}
nmnmnmnmnmnmnm