結果
問題 | No.3068 Speedrun (Hard) |
ユーザー |
|
提出日時 | 2025-03-21 23:38:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,307 ms / 2,000 ms |
コード長 | 885 bytes |
コンパイル時間 | 1,991 ms |
コンパイル使用メモリ | 195,348 KB |
実行使用メモリ | 7,328 KB |
最終ジャッジ日時 | 2025-03-21 23:38:41 |
合計ジャッジ時間 | 13,374 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 32 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; #include<atcoder/modint> using namespace atcoder; using mint=modint998244353; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); //maybe TLE or MLE ll A[5],P[5]; for(int i=0;i<5;i++)cin>>A[i]; for(int i=0;i<5;i++)cin>>P[i]; for(ll a=0;a<=A[0];a++){ for(ll b=0;b<=A[1];b++){ ll S=a*P[0]+b*P[1]; if(S>P[4])continue; ll M=A[4]-a-b; ll Z=P[4]-S; if(M<0)continue; if(P[2]==P[3]){ if(Z%P[2]!=0||M*P[2]!=Z)continue; if(A[2]+A[3]<M)continue; ll c=min(M,A[2]); ll d=M-c; cout<<a<<" "<<b<< " "<<c<<" "<<d<<endl; return 0; } else{ ll G=Z-M*P[2]; ll D=P[3]-P[2]; if(G%D!=0)continue; ll d=G/D; if(d<0||d>A[3])continue; ll c=M-d; if(c<0||c>A[2])continue; cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl; return 0; } } } }