結果
| 問題 |
No.281 門松と魔法(1)
|
| コンテスト | |
| ユーザー |
IL_msta
|
| 提出日時 | 2015-09-18 23:18:28 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,089 bytes |
| コンパイル時間 | 861 ms |
| コンパイル使用メモリ | 88,428 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-06 19:24:38 |
| 合計ジャッジ時間 | 2,390 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 46 WA * 11 |
ソースコード
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <vector>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define PII pair<int,int>
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////
vector<LL> H(3);
bool check(){
if( H[0] == H[1] || H[1] == H[2] || H[2] == H[1] ){
return false;
}else if( H[0] < H[1] && H[2] < H[1] ){
return true;
}else if( H[0] > H[1] && H[2] > H[1] ){
return true;
}
return false;
}
LL cut(LL A,LL B,LL C,LL d){
//A>B>C
LL ret = 0;
LL temp;
if( A <= B ){
temp = (B-A+d)/d;
if( temp < 0 ){
temp = (B+d-1) / d;
B = 0;
}else{
B = B - d*temp;
}
if( A > B && B > 0){
ret += temp;
}else{
return -1;
}
}
///////////////
if( B <= C ){
temp = (C-B+d)/d;
if( temp < 0 ){
temp = (C+d-1) / d;
C = 0;
}else{
C = C - d*temp;
}
if( B > C && C >= 0){
ret += temp;
}else{
return -1;
}
}
return ret;
}
void solve(){
LL d;
cin >> d;//
rep(i,3){
cin >> H[i];
}
if( 0 == d ){
if( check() ){
cout << 0 << endl;
}else{
cout << -1 << endl;
}
return;
}
//else if(H[0] >= 3*d && H[1]>= 3*d && H[2] >= 3*d){}
////
LL ret = -1;
LL temp;
//LL cut(int A,int B,int C,int d)
//(1,0,2)(1,2,0)(0,2,1)(2,0,1)
temp = cut(H[1],H[0],H[2],d);
if( temp >= 0 ){if( -1 == ret || temp < ret){ret = temp;}}
temp = cut(H[1],H[2],H[0],d);
if( temp >= 0 ){if( -1 == ret || temp < ret){ret = temp;}}
temp = cut(H[0],H[2],H[1],d);
if( temp >= 0 ){if( -1 == ret || temp < ret){ret = temp;}}
temp = cut(H[2],H[0],H[1],d);
if( temp >= 0 ){if( -1 == ret || temp < ret){ret = temp;}}
cout << ret << endl;
}
int main(void){
std::cin.tie(0);
std::ios::sync_with_stdio(false);
std::cout << std::fixed;//
//cout << setprecision(16);//
//cpp
solve();
return 0;
}
IL_msta