結果
| 問題 |
No.3068 Speedrun (Hard)
|
| コンテスト | |
| ユーザー |
tobbie
|
| 提出日時 | 2025-04-07 22:40:17 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 576 ms / 2,000 ms |
| コード長 | 844 bytes |
| コンパイル時間 | 1,802 ms |
| コンパイル使用メモリ | 194,784 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-04-07 22:40:26 |
| 合計ジャッジ時間 | 7,330 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 32 |
ソースコード
#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, 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 >= 0 && n4 >= 0 && n3*p[2] + n4*p[3] == t0) {
cout << n1 << " " << n2 << " " << n3 << " " << n4 << endl;
return 0;
}
}
}
return 0;
}
tobbie