結果
| 問題 |
No.281 門松と魔法(1)
|
| コンテスト | |
| ユーザー |
lattice
|
| 提出日時 | 2015-09-18 23:54:25 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,709 bytes |
| コンパイル時間 | 488 ms |
| コンパイル使用メモリ | 64,012 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-06 19:30:46 |
| 合計ジャッジ時間 | 1,963 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 45 WA * 12 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
int main()
{
int d;
cin >> d;
int h1, h2, h3;
cin >> h1 >> h2 >> h3;
if(d == 0)
{
if(h1 != h2 && h1 != h3 && h2 != h3)
{
if(h1 < h2 && h3 < h2)
{
cout << 0;
return 0;
}
if(h1 > h2 && h3 > h2)
{
cout << 0;
return 0;
}
}
cout << -1;
return 0;
}
if(h1 != h2 && h1 != h3 && h2 != h3)
{
if(h1 < h2 && h3 < h2)
{
cout << 0;
return 0;
}
if(h1 > h2 && h3 > h2)
{
cout << 0;
return 0;
}
if(h1 > h2 && h1 > h3) // h2 > h3
{
int temp = h1;
h1 = h3;
h3 = temp;
}
// h1 < h2 < h3
int mh3 = (h3 - h2) / d + 1;
int mh2 = (h2 - h1) / d + 1;
if(h2 - mh2*d >= 0 && h3 - mh3*d >= 0)
{
cout << min(mh2, mh3);
}
else if(h2 - mh2*d >= 0)
{
cout << mh2;
}
else if( h3 - mh3*d >= 0)
{
cout << mh3;
}
else
{
cout << -1;
}
return 0;
}
if(h1 == h2 == h3)
{
if(h1 - d*2 >= 0)
{
cout << 3;
}
else
{
cout << -1;
}
return 0;
}
if(h1 == h3)
{
if(h1 < d)
{
cout << -1;
}
else
{
if(h2 > h1)
{
cout << 1;
}
else
{
int mh3 = (h3 - h2) / d + 2;
if(h3 - mh3*d <0)
{
cout << -1;
}
else
{
cout << mh3 * 2 - 1;
}
}
}
return 0;
}
if(h1 == h2)
{
h1 = h3;
h3 = h2;
}
// h1 != h2 == h3
if(h1 < h2)
{
int mh3 = (h3 - h2) / d + 2;
if(h3 - mh3*d == h1) mh3++;
if(h3 - mh3*d < 0)
{
cout << -1;
}
else
{
cout << mh3;
}
return 0;
}
else
{
if(h2 >= d)
{
cout << 1;
}
else
{
cout << -1;
}
return 0;
}
cout << -1;
return 0;
}
lattice