結果
問題 |
No.3068 Speedrun (Hard)
|
ユーザー |
|
提出日時 | 2025-03-22 00:54:43 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,292 ms / 2,000 ms |
コード長 | 1,056 bytes |
コンパイル時間 | 4,904 ms |
コンパイル使用メモリ | 250,972 KB |
実行使用メモリ | 7,324 KB |
最終ジャッジ日時 | 2025-03-22 00:54:56 |
合計ジャッジ時間 | 12,209 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge7 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 32 |
ソースコード
#include <atcoder/all> #include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, s, t) for (ll i = s; i < (ll)(t); i++) #define all(x) begin(x), end(x) template <typename T> bool chmin(T &x, T y) { return x > y ? (x = y, true) : false; } template <typename T> bool chmax(T &x, T y) { return x < y ? (x = y, true) : false; } struct IOST { IOST() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20); } } IOST; int main(){ ll a,b,c,d,n; ll p,q,r,s,t; cin>>a>>b>>c>>d>>n; cin>>p>>q>>r>>s>>t; rep(x,0,a+1) rep(y,0,b+1){ ll nn=n-x-y; if(nn<0) break; ll tt=t-p*x-q*y; if(tt<0) break; if(r==s){ if(r*nn!=tt) continue; if(nn>c+d) continue; ll tmp=min(nn,c); assert(nn-tmp<=d); cout<<x<<" "<<y<<" "<<tmp<<" "<<nn-tmp<<"\n"; return 0; }else{ tt-=s*nn; if(t<0) continue; ll tz=tt/(r-s); if(tz*(r-s)!=tt) continue; if(tz<0||tz>c) continue; ll tw=nn-tz; if(tw<0||tw>d) continue; cout<<x<<" "<<y<<" "<<tz<<" "<<tw<<"\n"; return 0; } } }