結果
問題 |
No.2390 Udon Coupon (Hard)
|
ユーザー |
|
提出日時 | 2023-07-21 21:55:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 37 ms / 2,000 ms |
コード長 | 628 bytes |
コンパイル時間 | 826 ms |
コンパイル使用メモリ | 75,812 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-06 01:50:01 |
合計ジャッジ時間 | 2,497 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 47 |
ソースコード
#include<iostream> #include<vector> #include<algorithm> #include<cassert> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); long N;cin>>N; vector<pair<int,int> >A(3); for(int i=0;i<3;i++)cin>>A[i].first>>A[i].second; sort(A.begin(),A.end(),[](pair<int,int>l,pair<int,int>r) { return l.second*r.first>r.second*l.first; }); long ans=0; for(int y=0;y<A[0].first;y++)for(int z=0;z<A[0].first;z++) { long u=(long)y*A[1].first+(long)z*A[2].first; if(u<=N) { long x=(N-u)/A[0].first; ans=max(ans,x*A[0].second+(long)y*A[1].second+(long)z*A[2].second); } } cout<<ans<<endl; }