結果

問題 No.2390 Udon Coupon (Hard)
ユーザー x.t.x.t.
提出日時 2023-07-22 10:55:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 1,495 bytes
コンパイル時間 1,637 ms
コンパイル使用メモリ 165,352 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-15 21:07:25
合計ジャッジ時間 3,456 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 46 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 21 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 9 ms
6,944 KB
testcase_25 AC 10 ms
6,944 KB
testcase_26 AC 10 ms
6,940 KB
testcase_27 AC 11 ms
6,944 KB
testcase_28 AC 9 ms
6,944 KB
testcase_29 AC 23 ms
6,940 KB
testcase_30 AC 22 ms
6,940 KB
testcase_31 AC 22 ms
6,940 KB
testcase_32 AC 23 ms
6,944 KB
testcase_33 AC 23 ms
6,940 KB
testcase_34 AC 43 ms
6,944 KB
testcase_35 AC 39 ms
6,944 KB
testcase_36 AC 40 ms
6,944 KB
testcase_37 AC 40 ms
6,940 KB
testcase_38 AC 41 ms
6,940 KB
testcase_39 AC 23 ms
6,948 KB
testcase_40 AC 14 ms
6,944 KB
testcase_41 AC 22 ms
6,944 KB
testcase_42 AC 14 ms
6,940 KB
testcase_43 AC 13 ms
6,944 KB
testcase_44 AC 2 ms
6,944 KB
testcase_45 AC 4 ms
6,940 KB
testcase_46 AC 2 ms
6,940 KB
testcase_47 AC 2 ms
6,944 KB
testcase_48 AC 3 ms
6,944 KB
testcase_49 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 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];
	}
	if (a[1] * b[0] < a[0] * b[1]) {
		swap(a[0], a[1]);
		swap(b[0], b[1]);
	}
	if (a[2] * b[0] < a[0] * b[2]) {
		swap(a[0], a[2]);
		swap(b[0], b[2]);
	}
	ll mx=0;
	for(ll j=0;j<a[0];j++) {
		for(ll k=0;k<a[0];k++) {
			ll i=(n-j*a[1]-k*a[2])/a[0];
			if(i>=0&&i*a[0]+j*a[1]+k*a[2]<=n) {
				mx=max(mx,i*b[0]+j*b[1]+k*b[2]);
			}
		}
	}
	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;
}
0