結果

問題 No.818 Dinner time
ユーザー ats5515ats5515
提出日時 2019-04-20 18:15:49
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 758 bytes
コンパイル時間 1,174 ms
コンパイル使用メモリ 83,112 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-09 19:43:45
合計ジャッジ時間 2,234 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vector<int> A(N);
	vector<int> B(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> B[i] >> A[i];
	}
	vector<int> X(N + 1, 0);
	for (int i = N - 1; i >= 0; i--) {
		int t = max(A[i], B[i]);
		X[i] = max((int)0, X[i + 1] + t);
	}
	int a = 0;
	for (int i = 0; i < N; i++) {
		
		a += max(A[i], max(A[i] + (M - 1)* B[i], M*B[i]));
		//cerr << a + X[i + 1] << endl;
		res = max(res, a + X[i + 1]);
	}
	cout << res << endl;
}
0