結果

問題 No.281 門松と魔法(1)
ユーザー fmhrfmhr
提出日時 2015-09-18 23:59:40
言語 Go
(1.22.1)
結果
TLE  
実行時間 -
コード長 753 bytes
コンパイル時間 12,580 ms
コンパイル使用メモリ 227,968 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-04-24 11:44:04
合計ジャッジ時間 15,702 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,624 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 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 3 ms
5,376 KB
testcase_16 AC 37 ms
5,376 KB
testcase_17 AC 16 ms
5,376 KB
testcase_18 AC 67 ms
5,376 KB
testcase_19 AC 17 ms
5,376 KB
testcase_20 AC 4 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 76 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
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 #

package main

import (
	"fmt"
)

func main() {
	solve281()
}

func solve281(){
	var d, a, b, c int
	fmt.Scan(&d, &a, &b, &c)
	var cnt1, cnt2 int
	b1 := b
	for a<=b1||c<=b1{
		cnt1++
		b1 = max(0, b1-d)
		if b1==0{
			break
		}
	}
	if a==0||c==0{
		cnt1 = -1
	}

	a1:=a
	for a1>=b{
		cnt2++
		a1 = max(0, a1-d)
		if a1==0{
			break
		}
	}
	c1 := c
	for c1>=b{
		cnt2++
		c1= max(0, c1-d)
		if c1 == 0{
			break
		}
	}
	if  a1==c1||b==0{
		cnt2=-1
	}
	//fmt.Println(cnt1, cnt2)
	if cnt1==-1&&cnt2==-1{
		fmt.Println("-1")
	}else if cnt1==-1{
		fmt.Println(cnt2)
	}else if cnt2==-1{
		fmt.Println(cnt1)
	}else{
		fmt.Println(min(cnt1, cnt2))
	}

}

func max(a, b int)int{
	if a<b{
		a=b
	}
	return a
}

func min(a, b int)int{
	if a>b{
		a=b
	}
	return a
}
0