結果

問題 No.281 門松と魔法(1)
ユーザー かにかに
提出日時 2015-11-08 01:05:51
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,058 bytes
コンパイル時間 747 ms
コンパイル使用メモリ 93,248 KB
実行使用メモリ 13,756 KB
最終ジャッジ日時 2024-04-24 11:57:39
合計ジャッジ時間 3,734 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#define aLL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXISt(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define MAX 100000000
#define pb push_back
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;
int dx[] = { 0, 1, 0, -1 };
int dy[] = { -1, 0, 1, 0 };

int sttoi(std::string str) {
	int ret;
	std::stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

bool sort_greater(const pair<string, int> &a, const pair<string, int> &b) {
	return a.second > b.second;
}

void solve() {
	int d, a, b, c;
	cin >> d >> a >> b >> c;
	if (a != b && b != c && c != a){
		if (max(a, max(b, c)) == b || min(a, min(b, c)) == b){
			P(0);
			return;
		}
		else{
			if (max(a, max(b, c)) == a){
				int count = 0;
				while (a >= b){
					a = max(0,a-d);
					count++;
				}
				if (a == c){
					count++;
				}
				P(count);
				return;
			}
			else{
				int count = 0;
				while (c >= b){
					c = max(0, c - d);
					count++;
				}
				if (a == c){
					count++;
				}
				P(count);
				return;
			}
		}
	}
	else{
		if (a == b && b == c && c == a){
			if (a > d){
				P(3);
				return;
			}
			else{
				P(-1);
				return;
			}
		}
		else if (a == c && a < b){
			P(1);
			return;
		}
		else if (a == c && a > b){
			int gap = a - b;
			P((gap / d) * 2 + 1);
			return;
		}
	}
}

int main() {
	solve();
	return 0;
}
0