結果

問題 No.818 Dinner time
ユーザー chocoruskchocorusk
提出日時 2019-05-17 21:06:25
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 855 bytes
コンパイル時間 717 ms
コンパイル使用メモリ 96,308 KB
実行使用メモリ 6,800 KB
最終ジャッジ日時 2023-10-17 07:26:42
合計ジャッジ時間 4,911 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,800 KB
testcase_01 AC 4 ms
6,800 KB
testcase_02 AC 4 ms
6,800 KB
testcase_03 AC 4 ms
6,800 KB
testcase_04 AC 3 ms
6,800 KB
testcase_05 AC 4 ms
6,800 KB
testcase_06 AC 4 ms
6,800 KB
testcase_07 AC 4 ms
6,800 KB
testcase_08 AC 4 ms
6,800 KB
testcase_09 AC 3 ms
6,800 KB
testcase_10 AC 4 ms
6,800 KB
testcase_11 AC 4 ms
6,800 KB
testcase_12 AC 4 ms
6,800 KB
testcase_13 AC 4 ms
6,800 KB
testcase_14 AC 4 ms
6,800 KB
testcase_15 AC 4 ms
6,800 KB
testcase_16 AC 4 ms
6,800 KB
testcase_17 AC 51 ms
6,800 KB
testcase_18 AC 37 ms
6,800 KB
testcase_19 AC 40 ms
6,800 KB
testcase_20 AC 52 ms
6,800 KB
testcase_21 AC 47 ms
6,800 KB
testcase_22 AC 36 ms
6,800 KB
testcase_23 AC 42 ms
6,800 KB
testcase_24 AC 60 ms
6,800 KB
testcase_25 AC 42 ms
6,800 KB
testcase_26 AC 36 ms
6,800 KB
testcase_27 AC 53 ms
6,800 KB
testcase_28 AC 44 ms
6,800 KB
testcase_29 AC 56 ms
6,800 KB
testcase_30 AC 48 ms
6,800 KB
testcase_31 AC 52 ms
6,800 KB
testcase_32 AC 44 ms
6,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n; ll m; cin>>n>>m;
  ll a[100010], b[100010];
  for(int i=1; i<=n; i++){
    cin>>a[i]>>b[i];
  }
  ll s[100010], s2[100010]; s[0]=0, s2[0]=0;
  for(int i=1; i<=n; i++){
    s[i]=s[i-1]+max({m*a[i], (m-1)*a[i]+b[i], b[i]});
  }
  for(int i=1; i<=n; i++){
    s2[i]=s2[i-1]+max(a[i], b[i]);
  }
  ll mx=-1e18;
  ll ans=-1e18;
  for(int i=n; i>=1; i--){
    mx=max(mx, s2[i]);
    ans=max(ans, mx-s2[i]+s[i]);
  }
  cout<<ans<<endl;
	return 0;
}
0