結果

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

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;
#define us unsigned
#define ll long long
#define db double
#define ldb long double
#define pb push_back
#define rs resize
#define il inline
#define For(i,a,b) for(ll i=(a);i<=(b);++i)
#define Rep(i,a,b) for(ll i=(a);i>=(b);--i)
//#define getchar getchar_unlocked
inline ll read(){
	ll num=0,f=1;char c=getchar();
	while(c>'9' || c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' && c<='9')num=(num<<3)+(num<<1)+(c^48),c=getchar();
	return num*f;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10^48);
}
const ll N=1e5+5;
ll n,m,a[N],b[N],ans=-1e18,f[N];
int main(){
	//ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	//freopen("remake.in","r",stdin);
	//freopen("remake.out","w",stdout);
	n=read(),m=read();
	For(i,1,n){
		a[i]=read(),b[i]=read();
	}
	For(i,1,n){
		ll res=b[i],
		res1=a[i]*m,
		res2=a[i]*(m-1)+b[i],
    res3=a[i];
		f[i]=f[i-1]+max({res,res1,res2,res3});
		ans=max(ans,f[i]);
	}
	write(ans);
	return 0;
}
0