結果

問題 No.818 Dinner time
ユーザー 👑 emthrmemthrm
提出日時 2019-04-19 23:16:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,665 bytes
コンパイル時間 1,162 ms
コンパイル使用メモリ 125,424 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 12:27:54
合計ジャッジ時間 2,832 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,348 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; long long m; cin >> n >> m;
  vector<int> a(n), b(n); REP(i, n) cin >> a[i] >> b[i];
  long long ans = 0;
  long long dp1 = 0, dp2 = 0, dp3 = 0;
  REP(i, n) {
    long long tmp1 = max({dp1, dp2, dp3}) + b[i];
    long long tmp2 = max({dp1, dp2, dp3}) + a[i];
    long long tmp3 = max(dp2, dp3) + (m - 1) * a[i];
    long long tmp4 = dp3 + (m - 1) * a[i] + b[i];
    long long tmp5 = dp3 + m * a[i];
    ans = max({ans, tmp1, tmp2, tmp3, tmp4, tmp5});
    // dp1 = max({tmp1, tmp2, tmp3, tmp4, tmp5});
    // dp2 = max({tmp1, tmp3, tmp4, tmp5});
    // dp3 = max({tmp1, tmp4, tmp5});
    dp1 = max(tmp1, tmp2);
    dp2 = tmp3;
    dp3 = max(tmp4, tmp5);
  }
  cout << ans << '\n';
  return 0;
}
0