結果

問題 No.818 Dinner time
ユーザー tekihei2317tekihei2317
提出日時 2019-04-19 22:39:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 723 bytes
コンパイル時間 1,776 ms
コンパイル使用メモリ 169,952 KB
実行使用メモリ 7,896 KB
最終ジャッジ日時 2023-10-24 05:50:04
合計ジャッジ時間 4,083 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int INF=1e18;

signed main()
{
    int N,M; cin>>N>>M;
    vint a(N),b(N),c(N);
    REP(i,N) cin>>a[i]>>b[i],c[i]=max(a[i],b[i]);

    vint sumA(N+1),sumB(N+1),sumC(N+1);
    REP(i,N){
        sumA[i+1]=sumA[i]+a[i];
        sumB[i+1]=sumB[i]+b[i];
        sumC[i+1]=sumC[i]+c[i];
    }

    int x=-INF,y=-INF;
    for(int i=1;i<=N;i++){
        x=max(x,sumA[i]);
        y=max(y,sumC[i]);
    }
    int ans=(M-1)*x+y;
    ans=max(ans,sumB[N]+(M-1)*max(x,0LL));
    cout<<ans<<endl;
}
0