結果
問題 | No.818 Dinner time |
ユーザー |
![]() |
提出日時 | 2019-04-19 22:16:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 552 bytes |
コンパイル時間 | 1,665 ms |
コンパイル使用メモリ | 194,860 KB |
最終ジャッジ日時 | 2025-01-07 02:43:28 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 4 WA * 25 |
ソースコード
#include<bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} //INSERT ABOVE HERE signed main(){ Int n,m; cin>>n>>m; vector<Int> a(n),b(n); for(Int i=0;i<n;i++) cin>>a[i]>>b[i]; Int ans=-1e9; Int res=0,dif=0,val=0; for(Int i=0;i<n;i++){ res+=max(a[i],b[i]); dif+=a[i]; chmax(val,dif); chmax(ans,res+val*(m-1)); } cout<<ans<<endl; return 0; }