結果

問題 No.3068 Speedrun (Hard)
ユーザー friedrice
提出日時 2025-02-21 17:38:44
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 870 ms / 2,000 ms
コード長 824 bytes
コンパイル時間 3,700 ms
コンパイル使用メモリ 273,780 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-02-21 17:38:54
合計ジャッジ時間 10,028 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	int A, B, C, D, N, P, Q, R, S, T;
	cin >> A >> B >> C >> D >> N >> P >> Q >> R >> S >> T;
	for(int i = 0; i <= A; i++) {
		for(int j = 0; j <= B; j++) {
			int tim = T - i * P - j * Q, cnt = N - i - j;
			if(cnt < 0 || tim < 0) {
				continue;
			}
			if(R == S) {
				if(R * cnt != tim) {
					continue;
				}
				if(C + D < cnt) {
					continue;
				}
				int tmp = min(cnt, C);
				cout << i << ' ' << j << ' ' << tmp << ' ' << cnt - tmp << endl;
				return 0;
			}
			if((tim - S * cnt) % (R - S) != 0 || (tim - R * cnt) % (S - R) != 0) {
				continue;
			}
			int k = (tim - S * cnt) / (R - S), l = (tim - R * cnt) / (S - R);
			if(0 <= k && k <= C && 0 <= l && l <= D) {
				cout << i << ' ' << j << ' ' << k << ' ' << l << endl;
				return 0;
			}
		}
	}
}
0