結果
| 問題 |
No.818 Dinner time
|
| コンテスト | |
| ユーザー |
tekihei2317
|
| 提出日時 | 2019-04-19 22:32:43 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 682 bytes |
| コンパイル時間 | 1,517 ms |
| コンパイル使用メモリ | 170,316 KB |
| 実行使用メモリ | 7,040 KB |
| 最終ジャッジ日時 | 2024-09-22 22:19:50 |
| 合計ジャッジ時間 | 3,489 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 4 WA * 25 |
ソースコード
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int> vint;
typedef pair<int,int> pint;
const int INF=1e18;
signed main()
{
int N,M; cin>>N>>M;
vint a(N),b(N),c(N);
REP(i,N) cin>>a[i]>>b[i],c[i]=max(a[i],b[i]);
vint sumA(N+1),sumC(N+1);
REP(i,N){
sumA[i+1]=sumA[i]+a[i];
sumC[i+1]=sumC[i]+c[i];
}
int x=-INF,y=-INF;
for(int i=1;i<=N;i++){
x=max(x,sumA[i]);
y=max(y,sumC[i]);
}
int ans=(M-1)*x+y;
ans=max(ans,sumC[N]+(M-1)*max(x,0LL));
cout<<ans<<endl;
}
tekihei2317