結果

問題 No.818 Dinner time
ユーザー ahe100ahe100
提出日時 2019-04-20 01:36:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 754 bytes
コンパイル時間 1,579 ms
コンパイル使用メモリ 168,004 KB
実行使用メモリ 7,448 KB
最終ジャッジ日時 2023-10-24 22:54:03
合計ジャッジ時間 3,389 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,680 KB
testcase_01 AC 2 ms
5,680 KB
testcase_02 AC 2 ms
5,680 KB
testcase_03 AC 2 ms
5,680 KB
testcase_04 AC 2 ms
5,680 KB
testcase_05 AC 2 ms
5,680 KB
testcase_06 AC 3 ms
5,680 KB
testcase_07 AC 2 ms
5,680 KB
testcase_08 AC 2 ms
5,680 KB
testcase_09 WA -
testcase_10 AC 2 ms
5,680 KB
testcase_11 WA -
testcase_12 AC 2 ms
5,680 KB
testcase_13 AC 2 ms
5,680 KB
testcase_14 AC 2 ms
5,680 KB
testcase_15 AC 2 ms
5,680 KB
testcase_16 AC 3 ms
5,680 KB
testcase_17 AC 51 ms
7,428 KB
testcase_18 AC 36 ms
6,928 KB
testcase_19 AC 40 ms
6,956 KB
testcase_20 AC 51 ms
7,328 KB
testcase_21 AC 47 ms
7,120 KB
testcase_22 AC 35 ms
6,844 KB
testcase_23 AC 41 ms
6,984 KB
testcase_24 AC 60 ms
7,448 KB
testcase_25 AC 41 ms
6,976 KB
testcase_26 AC 34 ms
6,812 KB
testcase_27 AC 52 ms
7,252 KB
testcase_28 AC 43 ms
7,020 KB
testcase_29 AC 56 ms
7,356 KB
testcase_30 AC 47 ms
7,148 KB
testcase_31 AC 51 ms
7,232 KB
testcase_32 AC 43 ms
7,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
dp(i,j) = i番目をj個使う
実はjは0 or 1 or Mに限られる
*/

ll n,m,a[100010],b[100010],dp[100010][3];

void init(){
	cin>>n>>m;
	reg(i,1,n)cin>>a[i]>>b[i];
	rep(j,3)dp[0][j]=0;
}

int main(void){
	init();
	reg(i,1,n){
		dp[i][0]=max({dp[i-1][0],dp[i-1][1],dp[i-1][2]});
		dp[i][1]=max(dp[i-1][1],dp[i-1][2])+max(a[i],b[i]);
		dp[i][2]=dp[i-1][2]+max({a[i]*m,a[i]*(m-1)+b[i],b[i]});
	}
	cout<<max({dp[n][0],dp[n][1],dp[n][2]})<<endl;
	return 0;
}
0