結果
問題 |
No.281 門松と魔法(1)
|
ユーザー |
![]() |
提出日時 | 2016-03-31 23:43:11 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 899 bytes |
コンパイル時間 | 595 ms |
コンパイル使用メモリ | 84,100 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-06 19:51:15 |
合計ジャッジ時間 | 2,674 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 WA * 17 RE * 5 |
ソースコード
/* -*- coding: utf-8 -*- * * 281.cc: No.281 門松と魔法(1) - yukicoder */ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<string> #include<vector> #include<map> #include<set> #include<stack> #include<list> #include<queue> #include<deque> #include<algorithm> #include<numeric> #include<utility> #include<complex> #include<functional> using namespace std; /* constant */ /* typedef */ /* global variables */ /* subroutines */ /* main */ int main() { int d, h0, h1, h2; cin >> d >> h0 >> h1 >> h2; if (h1 == 0 && (h0 == 0 || h2 == 0)) { puts("-1"); return 0; } // h0 < h1 > h2 int c0 = 0; if (h0 >= h1) c0 += (h0 - h1) / d + 1; if (h2 >= h1) c0 += (h2 - h1) / d + 1; // h0 > h1 < h2 int mh = min(h0, h2); int c1 = 0; if (h1 >= mh) c1 += (h1 - mh) / d + 1; printf("%d\n", min(c0, c1)); return 0; }