結果

問題 No.818 Dinner time
ユーザー okok
提出日時 2019-04-20 10:29:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 852 bytes
コンパイル時間 707 ms
コンパイル使用メモリ 71,144 KB
実行使用メモリ 4,932 KB
最終ジャッジ日時 2023-10-25 23:46:24
合計ジャッジ時間 3,313 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 19 ms
4,912 KB
testcase_18 AC 13 ms
4,416 KB
testcase_19 AC 14 ms
4,440 KB
testcase_20 AC 18 ms
4,816 KB
testcase_21 AC 17 ms
4,604 KB
testcase_22 AC 14 ms
4,348 KB
testcase_23 AC 15 ms
4,472 KB
testcase_24 AC 21 ms
4,932 KB
testcase_25 AC 15 ms
4,460 KB
testcase_26 AC 13 ms
4,348 KB
testcase_27 AC 19 ms
4,736 KB
testcase_28 AC 15 ms
4,504 KB
testcase_29 AC 20 ms
4,840 KB
testcase_30 AC 17 ms
4,632 KB
testcase_31 AC 19 ms
4,716 KB
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 110000

int N, M;
int a, b;
int hoge[MAX][2];

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int ans = 0, temp, x = 0, num = 0;
	
	cin>>N>>M>>a>>b;
	
	x =  max(b,a*(M-1)+max(a,b));
	
	for(signed i = 1; i < N; i++){
		cin>>a>>b;
		
		num = max(a,b);
		
		temp = max(b,a*(M-1)+num);
		
		hoge[i+1][0] = max(hoge[i][0],hoge[i][1]) +num;
		
		ans = max(ans,max(hoge[i+1][1] += temp+hoge[i][1],hoge[i+1][1]));
		
	}
	
	ans += x;
	
	cout<<ans<<endl;
	
	return 0;
}
0