結果

問題 No.281 門松と魔法(1)
ユーザー sortreew
提出日時 2015-09-18 22:43:57
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,043 bytes
コンパイル時間 1,755 ms
コンパイル使用メモリ 159,128 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-06 18:43:20
合計ジャッジ時間 3,209 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 37 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef int ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
typedef priority_queue<ppr,Vppr,greater<ppr> > PprQ;
const int SIZE=5+3*1e+5;
const LL INF=1LL<<60;
const ld eps=1e-6;
const LL p=7+1e+9;
LL nums[SIZE];
int main(){
	string s;
	LL d,H[3];
	cin >> d;
	REP(i,3)
		cin >> H[i];
	LL ans=INF;
	if(H[1]<min(H[2],H[0]) || H[1]>max(H[2],H[0])) {
		cout << 0 << endl;
		return 0;
	}
	if(d==0 || (H[0]==0 && H[2]==0)){
		cout << -1 << endl;
		return 0;
	}
	ans=min(ans,(H[1]-min(H[0],H[2]))/d+1);
	ans=min(ans,max(0LL,H[2]-H[1]+d)/d+max(0LL,H[0]-H[1]+d)/d);
	cout << ans << endl;
	return 0;
}
0