結果
| 問題 |
No.2390 Udon Coupon (Hard)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-22 10:35:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,555 bytes |
| コンパイル時間 | 1,596 ms |
| コンパイル使用メモリ | 166,888 KB |
| 実行使用メモリ | 13,752 KB |
| 最終ジャッジ日時 | 2024-09-22 10:47:30 |
| 合計ジャッジ時間 | 6,747 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 4 WA * 2 TLE * 1 -- * 40 |
ソースコード
// Problem: No.2386 Udon Coupon (Easy)No.2386 乌冬面优惠券 (简易)
// Contest: yukicoder
// URL: https://yukicoder.me/problems/no/2386
// Memory Limit: 512 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
ll ksm(ll n,ll p,int mod){
int ans=1;
while(p){
if(p&1) ans=(ans*n)%mod;
n=(n*n)%mod;p>>=1;
}
return ans;
}
ll inv(ll b,ll c=mod) {return ksm(b,c-2,c);}
class Num{
public:
ll num;
Num(ll x) {num=(x%mod+mod)%mod;}
Num operator+(Num p) {return Num(num+p.num);}
Num operator-(Num p) {return Num(num-p.num);}
Num operator*(Num p) {return Num(num*p.num);}
Num operator/(Num p) {return Num(num*inv(p.num));}
Num operator=(Num p) {this->num=p.num;return *this;}
friend ll get(Num p) {return p.num;}
};
ll a[3],b[3];
void solve() {
ll n;
cin>>n;
for(int i=0;i<3;i++) {
cin>>a[i]>>b[i];
}
ll mx=0;
for(ll x=0;x<=n;x+=a[0]) {
ll res=x/a[0]*b[0],m=n-x;
ll t1=x/3,t2=0,t3=0;
if(b[1]*a[2]>=a[1]*b[2]) {
res+=(m/a[1])*b[1];
t2+=(m/a[1]);
m%=a[1];
}
else {
res+=(m/a[2])*b[2];
t3+=m/a[2];
m%=a[2];
}
if(a[1]<=a[2]) {
res+=(m/a[1])*b[1];
t2+=m/a[1];
m%=a[1];
}
else {
res+=(m/a[2])*b[2];
t2+=m/a[2];
m%=a[2];
}
mx=max(mx,res);
}
cout<<mx<<endl;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int T=1;
//cin>>T;
while(T--) {
solve();
}
return 0;
}