結果

問題 No.3068 Speedrun (Hard)
ユーザー tobbie
提出日時 2025-04-07 22:33:53
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 826 bytes
コンパイル時間 1,834 ms
コンパイル使用メモリ 194,916 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-04-07 22:34:02
合計ジャッジ時間 7,581 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define rep(i, n) for (int i = 0; i < (int)n; i++)

int main() {
  vector<int> a(4);
  rep(i, 4) cin >> a[i];
  int n; cin >> n;
  vector<int> p(4);
  rep(i, 4) cin >> p[i];
  int t; cin >> t;
  for (int n1=0, t1=0; n1<=a[0] && t1<=t; n1++, t1+=p[0]) {
    int n2max = min(a[1], n - n1);
    int t2max = t - t1;
    for (int n2=0, t2=0; n2<=n2max && t2<=t2max; n2++, t2+= p[1]) {
      int n0 = n - (n1 + n2);
      int t0 = t - (t1 + t2);
      int n3 = 0, n4 = 0;
      if (p[2] == p[3]) {
	n3 = min(n0 / 2, a[2]);
	n4 = min(n0 - n3, a[3]);
      } else {
	n3 = min((t0 - n0*p[3])/(p[2] - p[3]), a[2]);
	n4 = min(n0 - n3, a[3]);
      }
      if (n3*p[2] + n4*p[3] == t0) {
	cout << n1 << " " << n2 << " " << n3 << " " << n4 << endl;
	return 0;
      }
    }
  }
  return 0;
}
0