結果
問題 | No.818 Dinner time |
ユーザー |
![]() |
提出日時 | 2019-04-20 09:43:50 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 56 ms / 2,000 ms |
コード長 | 1,098 bytes |
コンパイル時間 | 1,167 ms |
コンパイル使用メモリ | 133,104 KB |
最終ジャッジ日時 | 2025-01-07 02:46:27 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 29 |
ソースコード
#include<iomanip> #include<limits> #include<thread> #include<utility> #include<iostream> #include<string> #include<algorithm> #include<set> #include<map> #include<vector> #include<stack> #include<queue> #include<cmath> #include<numeric> #include<cassert> #include<random> #include<chrono> #include<unordered_set> #include<unordered_map> #include<fstream> #include<list> #include<functional> #include<bitset> #include<complex> #include<tuple> using namespace std; typedef unsigned long long int ull; typedef long long int ll; typedef pair<ll,ll> pll; typedef pair<int,int> pi; typedef pair<double,double> pd; typedef pair<double,ll> pdl; #define F first #define S second const ll E=1e18+7; const ll MOD=1000000007; int main(){ ll n,m; cin>>n>>m; vector<pll> A(n); ll ans=-E; ll sum=0; ll meat=0; ll egg=-E; for(auto &I:A){cin>>I.F>>I.S;} for(auto &I:A){ meat+=max(I.F,I.S); sum+=max(max(I.F*m,I.F*(m-1)+I.S),I.S)-max(I.F,I.S); if(sum>egg){egg=sum;} ans=max(ans,egg+meat); } cout<<ans<<endl; return 0; }