結果

問題 No.3068 Speedrun (Hard)
ユーザー MM
提出日時 2025-03-21 21:45:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,200 bytes
コンパイル時間 3,802 ms
コンパイル使用メモリ 251,668 KB
実行使用メモリ 7,328 KB
最終ジャッジ日時 2025-03-21 21:45:56
合計ジャッジ時間 12,824 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include"bits/stdc++.h"
#include"atcoder/all"
#define chmin(x,y) (x) = min((x),(y))
#define chmax(x,y) (x) = max((x),(y))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec vector
#define all(a) a.begin(), a.end()
#define pb push_back 

using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
const ll mod = 998244353;
using mint = modint998244353;
using Graph = vector<vector<pair<int,ll>>>;
const vector<int> dx = {1,0,-1,0}, dy = {0,1,0,-1};

int main(){
	// input
	int A,B,C,D,N,P,Q,R,S,T;
	cin >> A >> B >> C >> D >> N;
	cin >> P >> Q >> R >> S >> T;
	
	// solve
	bool found = 0;
	for(int a = 0; a <= A; a++){
		for(int b = 0; b <= B; b++){
			if(a + b > N || a * P + b * Q > T) break;
			
			ll M = N - (a + b), U = T - a * P - b * Q;
			U -= M * R;
			if(S != R){
				if(U % (S-R) == 0){
					int c = M - U / (S-R), d = U / (S-R);
					if(c <= C && d <= D){
						printf("%d %d %d %d\n", a, b, c, d);
						found = 1;
						break;
					}
				}
			}
			else if (U == 0 && C + D <= M){
				int c = min(int(M),C);
				int d = M - c;
				printf("%d %d %d %d\n", a, b, c, d);
				found = 1;
				break;
			}
		}
		if(found) break;
	}
	return (0);
}
0