結果

問題 No.818 Dinner time
ユーザー tubuanntubuann
提出日時 2019-04-20 09:43:50
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 1,098 bytes
コンパイル時間 1,213 ms
コンパイル使用メモリ 136,412 KB
実行使用メモリ 4,580 KB
最終ジャッジ日時 2023-08-20 00:53:27
合計ジャッジ時間 3,346 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 47 ms
4,380 KB
testcase_18 AC 33 ms
4,380 KB
testcase_19 AC 37 ms
4,380 KB
testcase_20 AC 46 ms
4,380 KB
testcase_21 AC 43 ms
4,376 KB
testcase_22 AC 34 ms
4,380 KB
testcase_23 AC 38 ms
4,376 KB
testcase_24 AC 55 ms
4,560 KB
testcase_25 AC 38 ms
4,500 KB
testcase_26 AC 32 ms
4,380 KB
testcase_27 AC 47 ms
4,380 KB
testcase_28 AC 40 ms
4,380 KB
testcase_29 AC 51 ms
4,376 KB
testcase_30 AC 44 ms
4,380 KB
testcase_31 AC 47 ms
4,580 KB
testcase_32 AC 39 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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=-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;
}


0