結果

問題 No.3068 Speedrun (Hard)
コンテスト
ユーザー ID 21712
提出日時 2025-03-21 23:58:13
言語 Go
(1.26.1)
コンパイル:
env GOCACHE=/tmp go build _filename_
実行:
./Main
結果
AC  
実行時間 299 ms / 2,000 ms
コード長 633 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 13,184 ms
コンパイル使用メモリ 298,548 KB
実行使用メモリ 9,228 KB
最終ジャッジ日時 2026-07-07 19:08:36
合計ジャッジ時間 13,573 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

package main

import . "fmt" 
//import . "math/rand"

func main() {
	var a,b,c,d,n,p,q,r,s,t int
	Scan(&a,&b,&c,&d,&n,&p,&q,&r,&s,&t)
	for w:=0;w<=a&&w<=n&&w*p<=t;w++ {
		t1:=t-w*p
		n1:=n-w
		for x:=0;x<=b&&x<=n1&&x*q<=t1;x++ {
			t2:=t1-x*q
			n2:=n1-x
			// n2==y+z
			// t2==y*r+z*s
			// t2=y*r+(n2-y)*s
			// t2-n2*s=(r-s)*y
			if r==s {
				y:=n2
				z:=0
				if y>c {
					y=c
					z=n2-c
				}
				if z<=d&&t2==y*r+z*s {
					Println(w,x,y,z)
					return
				}
			} else {
				y:=(t2-n2*s)/(r-s)
				z:=n2-y
				if y>=0&&y<=c&&z>=0&&z<=d {
					if t2==y*r+z*s {
						Println(w,x,y,z)
						return
					}
				}
			}
		}
	}
}
0