結果
| 問題 |
No.3068 Speedrun (Hard)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-03-21 23:43:52 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 649 ms / 2,000 ms |
| コード長 | 1,419 bytes |
| コンパイル時間 | 2,382 ms |
| コンパイル使用メモリ | 195,008 KB |
| 実行使用メモリ | 7,324 KB |
| 最終ジャッジ日時 | 2025-03-21 23:44:00 |
| 合計ジャッジ時間 | 7,614 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 32 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> istream& operator >> (istream& is, vector<T>& vec) {
for(T& x : vec) is >> x;
return is;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int t, n;
vector<int> a(4), b(4);
cin >> a >> n >> b >> t;
const int d = b[2] - b[3];
for(int i = 0; i <= n && i <= a[0] && i * b[0] <= t; i++){
for(int j = 0; i + j <= n && j <= a[1] && i * b[0] + j * b[1] <= t; j++){
const int rt = t - (i * b[0] + j * b[1]);
const int r = n - (i + j);
// Ax + B * (r - x) = rt
// (A - B) * x + B * r == rt
int rhs = rt - b[3] * r;
if(rhs == 0 && r <= a[3]){
cout << i << " " << j << " " << 0 << " " << r << '\n';
return 0;
}
if(d == 0){
int c2 = min(a[2], r), c3 = r - c2;
if(b[2] * (c2 + c3) == rt && c3 <= a[3]){
cout << i << " " << j << " " << c2 << " " << c3 << '\n';
return 0;
}
}else{
int c2 = rhs / d, c3 = r - c2;
if(c2 * d == rhs && 0 <= c2 && c2 <= a[2] && 0 <= c3 && c3 <= a[3]){
cout << i << " " << j << " " << c2 << " " << c3 << '\n';
return 0;
}
}
}
}
}