結果

問題 No.818 Dinner time
コンテスト
ユーザー vjudge1
提出日時 2026-07-22 17:02:22
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 634 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,324 ms
コンパイル使用メモリ 208,300 KB
実行使用メモリ 6,656 KB
最終ジャッジ日時 2026-07-22 17:02:26
合計ジャッジ時間 4,214 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 9 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

//#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
using namespace std;
const int N = 1e5+10;
int n,m,a[N],b[N],f[N][2],ans; 
signed main(){
//	freopen("remake.in","r",stdin);
//	freopen("remake.out","w",stdout);
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> n >> m;
	for(int i = 1;i <= n;i ++){
		cin >> a[i] >> b[i];
	}
	for(int i = 1;i <= n;i ++){
		f[i][0]=f[i-1][0]+max(max(b[i],m*a[i]),(m-1)*a[i]+b[i]);
		f[i][1]=max(f[i-1][1],f[i-1][0])+max(a[i],b[i]);
		ans=max(f[i][0],f[i][1]);
	}
	cout << ans;
	return 0;
}
0