結果

問題 No.281 門松と魔法(1)
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-06-14 18:43:13
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,534 bytes
コンパイル時間 906 ms
コンパイル使用メモリ 79,008 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 12:05:27
合計ジャッジ時間 2,261 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 69 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 4 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 9 ms
5,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 70 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 WA -
testcase_31 AC 69 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 69 ms
5,376 KB
testcase_34 WA -
testcase_35 AC 70 ms
5,376 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};

int d;


int main(void){
	cin >> d;
	int l, m, r;
	cin >> l >> m >> r;

	if(l < m && m > r){
		//真ん中最大
		printf("0\n");
		return 0;
	}
	if(l > m && m < r){
		//真ん中最小
		printf("0\n");
		return 0;
	}

	if(l >= m && m >= r) swap(l, m);
	//lが一番小さくて、rが一番大きくなるように並び替えた。
	int sa_left = m - l;
	int sa_right = r - m;

	//printf("%d %d %d\n", l , m, r);
	if(sa_left <= sa_right){
		//真ん中を切ればいい
		//printf("1desu\n");
		int cnt = 0;
		while(l <= m){
			m -= d;
			if(m < 0) m = 0;
			cnt++;
			if(cnt > 100000000){
				printf("-1\n");
				return 0;
			}
		}
		printf("%d\n", cnt);
		return 0;
	}else{
		//右側を切ればいい
		//printf("2desu\n");
		int cnt = 0;
		while(m <= r){
			r -= d;
			if(r < 0) m = 0;
			cnt++;
			if(cnt > 100000000){
				printf("-1\n");
				return 0;
			}
		}
		printf("%d\n", cnt);
		return 0;
	}

	return 0;
}
0