結果

問題 No.818 Dinner time
ユーザー tubuanntubuann
提出日時 2019-04-20 09:38:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,134 bytes
コンパイル時間 1,662 ms
コンパイル使用メモリ 138,096 KB
実行使用メモリ 4,892 KB
最終ジャッジ日時 2023-10-25 22:23:35
合計ジャッジ時間 3,676 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,348 KB
testcase_11 WA -
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 47 ms
4,892 KB
testcase_18 AC 32 ms
4,364 KB
testcase_19 AC 36 ms
4,364 KB
testcase_20 AC 47 ms
4,628 KB
testcase_21 AC 45 ms
4,364 KB
testcase_22 AC 34 ms
4,348 KB
testcase_23 AC 38 ms
4,364 KB
testcase_24 AC 57 ms
4,892 KB
testcase_25 AC 39 ms
4,364 KB
testcase_26 AC 33 ms
4,348 KB
testcase_27 AC 48 ms
4,628 KB
testcase_28 AC 41 ms
4,364 KB
testcase_29 AC 54 ms
4,628 KB
testcase_30 AC 46 ms
4,364 KB
testcase_31 AC 49 ms
4,628 KB
testcase_32 AC 41 ms
4,364 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=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