結果
| 問題 |
No.3068 Speedrun (Hard)
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2025-03-21 21:39:57 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 365 ms / 2,000 ms |
| コード長 | 1,500 bytes |
| コンパイル時間 | 785 ms |
| コンパイル使用メモリ | 76,380 KB |
| 実行使用メモリ | 52,480 KB |
| 最終ジャッジ日時 | 2025-03-21 21:40:03 |
| 合計ジャッジ時間 | 5,289 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 32 |
ソースコード
#ifdef NACHIA
#define _GLIBCXX_DEBUG
#else
#define NDEBUG
#endif
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(i64 i=0; i<i64(n); i++)
const i64 INF = 1001001001001001001;
template<typename A> void chmin(A& l, const A& r){ if(r < l) l = r; }
template<typename A> void chmax(A& l, const A& r){ if(l < r) l = r; }
using namespace std;
#include <bitset>
void testcase(){
bitset<400000001> buf;
i64 a,b,c,d,n,p,q,r,s,t; cin >> a >> b >> c >> d >> n >> p >> q >> r >> s >> t;
for(i64 k=0; k<=a+b; k++) if(n-k<=c+d){
for(i64 i=max<i64>(0,k-b); i<=a && i<=k; i++){
buf.set(p*i+q*(k-i));
}
i64 l = n - k;
i64 u=-1,v=-1,x=-1,y=-1;
for(i64 i=max<i64>(0,l-d); i<=c && i<=l; i++){
if(t - (r*i+s*(l-i)) >= 0 && buf.test(t - (r*i+s*(l-i)))){
x=i; y=l-i;
break;
}
}
if(x == -1){
for(i64 i=max<i64>(0,k-b); i<=a && i<=k; i++){
buf.reset(p*i+q*(k-i));
}
} else {
t -= r*x+s*y;
for(i64 i=max<i64>(0,k-b); i<=a && i<=k; i++){
if(p*i+q*(k-i) == t){ u=i; v=k-i; }
}
cout << u << " " << v << " " << x << " " << y << "\n";
return;
}
}
}
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
rep(f,1) testcase();
return 0;
}
Nachia