結果

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

ソースコード

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]) {
      if (p[2] == p[3]) {
	int n3 = n - (n1+n2);
	if (n3 % 2 == 0 && p[2] * n3 == t) {
	  cout << n1 << " " << n2 << " " << n3/2 << " " << n3/2 << endl;
	  return 0;
	}
      } else {
	int n0 = n - (n1 + n2);
	int t0 = t - (t1 + t2);
	if ((t0 - n0*p[3]) % (p[2] - p[3]) == 0) {
	  int n3 = (t0 - n0*p[3])/(p[2] - p[3]);
	  if (n3 <= a[2]) {
	    int n4 = n0 - n3;
	    if (n4 <= a[3]) {
	      cout << n1 << " " << n2 << " " << n3 << " " << n4 << endl;
	      return 0;
	    }
	  }
	}
      }
    }
  }
  return 0;
}
0