結果

問題 No.818 Dinner time
ユーザー tubuann
提出日時 2019-04-20 09:38:23
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,134 bytes
コンパイル時間 1,366 ms
コンパイル使用メモリ 132,972 KB
最終ジャッジ日時 2025-01-07 02:46:12
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#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=0;
    for(auto &I:A){cin>>I.F>>I.S;}
    for(auto &I:A){
        meat+=max(I.F,I.S);
        if(I.F<0 && I.F>I.S){sum+=max(I.F*m-I.F,I.S-I.F);}
        else if(I.F>0){sum+=I.F*(m-1);}
        if(sum>egg){egg=sum;}
        ans=max(ans,egg+meat);
    }
    cout<<ans<<endl;
    
    
    return 0;
}

0