Submission #1275849


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
	int N;
	cin >> N;
	vector<ll> A(N), B(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}
	ll res = 0, tmp = 0, ma = 0;
	for(int i = 0, j = 0; i < N && j < N; i++) {
		res = max(res, tmp + (N - j) * B[i]);
		ma = max(ma, B[i]);
		tmp += A[i];
		j++;
		if (tmp < 0) {
			ll di = -tmp;
			if (ma == 0) {
				break;
			}
			di = (di + ma - 1) / ma;
			tmp += di * ma;
			j += di;
		}
		res = max(res, tmp + (N - j) * ma);
	}
	cout << res << endl;
	return 0;
}

Submission Info

Submission Time
Task D - 高橋君の旅行
User kazuma
Language C++14 (GCC 5.4.1)
Score 200
Code Size 625 Byte
Status AC
Exec Time 85 ms
Memory 1920 KB

Judge Result

Set Name Small All
Score / Max Score 3 / 3 197 / 197
Status
AC × 13
AC × 49
Set Name Test Cases
Small 00_small_sample_00.txt, 00_small_sample_01.txt, 00_small_sample_02.txt, 00_small_sample_03.txt, 10_small_01.txt, 10_small_02.txt, 10_small_03.txt, 10_small_04.txt, 10_small_05.txt, 10_small_06.txt, 90_small_teuchi_00.txt, 90_small_teuchi_01.txt, 90_small_teuchi_02.txt
All 00_small_sample_00.txt, 00_small_sample_01.txt, 00_small_sample_02.txt, 00_small_sample_03.txt, 10_small_01.txt, 10_small_02.txt, 10_small_03.txt, 10_small_04.txt, 10_small_05.txt, 10_small_06.txt, 20_large_01.txt, 20_large_02.txt, 20_large_03.txt, 20_large_04.txt, 20_large_05.txt, 20_large_06.txt, 20_large_07.txt, 20_large_08.txt, 20_large_09.txt, 20_large_10.txt, 20_large_11.txt, 20_large_12.txt, 20_large_13.txt, 20_large_14.txt, 20_large_15.txt, 20_large_16.txt, 20_large_17.txt, 20_large_18.txt, 20_large_19.txt, 20_large_20.txt, 20_large_21.txt, 20_large_22.txt, 20_large_23.txt, 20_large_24.txt, 20_large_25.txt, 20_large_26.txt, 20_large_27.txt, 20_large_28.txt, 20_large_29.txt, 20_large_30.txt, 30_run_through_01.txt, 70_maximum_01.txt, 80_hand_01.txt, 80_hand_02.txt, 80_hand_03.txt, 80_hand_04.txt, 90_small_teuchi_00.txt, 90_small_teuchi_01.txt, 90_small_teuchi_02.txt
Case Name Status Exec Time Memory
00_small_sample_00.txt AC 1 ms 256 KB
00_small_sample_01.txt AC 1 ms 256 KB
00_small_sample_02.txt AC 1 ms 256 KB
00_small_sample_03.txt AC 1 ms 256 KB
10_small_01.txt AC 1 ms 256 KB
10_small_02.txt AC 1 ms 256 KB
10_small_03.txt AC 1 ms 256 KB
10_small_04.txt AC 1 ms 256 KB
10_small_05.txt AC 1 ms 256 KB
10_small_06.txt AC 1 ms 256 KB
20_large_01.txt AC 71 ms 1792 KB
20_large_02.txt AC 83 ms 1792 KB
20_large_03.txt AC 84 ms 1792 KB
20_large_04.txt AC 72 ms 1792 KB
20_large_05.txt AC 84 ms 1792 KB
20_large_06.txt AC 83 ms 1792 KB
20_large_07.txt AC 71 ms 1792 KB
20_large_08.txt AC 83 ms 1792 KB
20_large_09.txt AC 83 ms 1792 KB
20_large_10.txt AC 70 ms 1792 KB
20_large_11.txt AC 81 ms 1792 KB
20_large_12.txt AC 81 ms 1792 KB
20_large_13.txt AC 60 ms 1792 KB
20_large_14.txt AC 71 ms 1792 KB
20_large_15.txt AC 71 ms 1792 KB
20_large_16.txt AC 63 ms 1792 KB
20_large_17.txt AC 70 ms 1792 KB
20_large_18.txt AC 71 ms 1792 KB
20_large_19.txt AC 75 ms 1920 KB
20_large_20.txt AC 80 ms 1792 KB
20_large_21.txt AC 79 ms 1792 KB
20_large_22.txt AC 56 ms 1792 KB
20_large_23.txt AC 76 ms 1792 KB
20_large_24.txt AC 68 ms 1792 KB
20_large_25.txt AC 67 ms 1792 KB
20_large_26.txt AC 79 ms 1792 KB
20_large_27.txt AC 79 ms 1792 KB
20_large_28.txt AC 68 ms 1792 KB
20_large_29.txt AC 79 ms 1792 KB
20_large_30.txt AC 79 ms 1792 KB
30_run_through_01.txt AC 77 ms 1792 KB
70_maximum_01.txt AC 85 ms 1792 KB
80_hand_01.txt AC 34 ms 1792 KB
80_hand_02.txt AC 33 ms 1792 KB
80_hand_03.txt AC 35 ms 1792 KB
80_hand_04.txt AC 32 ms 1792 KB
90_small_teuchi_00.txt AC 1 ms 256 KB
90_small_teuchi_01.txt AC 1 ms 256 KB
90_small_teuchi_02.txt AC 1 ms 256 KB