Submission #1275894


Source Code Expand

#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int N; cin >> N;
	vector<long long int>as, bs;
	for (int i = 0; i < N; ++i) {
		int A; cin >> A;
		as.push_back(A);
	}
	for (int i = 0; i < N; ++i) {
		int B; cin >> B;
		bs.push_back(B);
	}
	long long int ans = 0;
	long long int rest = N;
	long long int money = 0;
	long long int maxstay = 0;
	for (int i = 0; i < N; ++i) {
		if (rest <= 0)break;
		maxstay = max(maxstay, bs[i]);
		ans = max(ans, money+maxstay * rest);
		if (money + as[i] >= 0) {
			rest--;
			money += as[i];
		}
		else {
			long long int need = -money - as[i];
			if (maxstay == 0)break;
			else {
				long long int needday = (need - 1) / maxstay+1;
				if (needday > rest - 1) {
					break;
				}
				else if (needday == rest - 1) {

					rest -= needday + 1;
					money = money + as[i] + maxstay*needday;
				}
				else {

					rest -= needday + 1;
					money = money + as[i] + maxstay*needday;
				}
			}
		}
	}
	cout << ans << endl;

	/*int T; cin >> T;
	while (T--) {
		int N; cin >> N;
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {

			}
		}
	}*/
	return 0;
}

Submission Info

Submission Time
Task D - 高橋君の旅行
User yuma000
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1475 Byte
Status WA
Exec Time 87 ms
Memory 2548 KB

Judge Result

Set Name Small All
Score / Max Score 0 / 3 0 / 197
Status
AC × 12
WA × 1
AC × 43
WA × 6
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 72 ms 2548 KB
20_large_02.txt AC 85 ms 2548 KB
20_large_03.txt AC 85 ms 2548 KB
20_large_04.txt AC 72 ms 2548 KB
20_large_05.txt AC 85 ms 2548 KB
20_large_06.txt AC 85 ms 2548 KB
20_large_07.txt AC 72 ms 2548 KB
20_large_08.txt AC 84 ms 2548 KB
20_large_09.txt AC 84 ms 2548 KB
20_large_10.txt AC 76 ms 2548 KB
20_large_11.txt AC 83 ms 2548 KB
20_large_12.txt AC 83 ms 2548 KB
20_large_13.txt AC 62 ms 2548 KB
20_large_14.txt AC 72 ms 2548 KB
20_large_15.txt AC 77 ms 2548 KB
20_large_16.txt AC 60 ms 2548 KB
20_large_17.txt AC 71 ms 2548 KB
20_large_18.txt AC 71 ms 2548 KB
20_large_19.txt WA 69 ms 2548 KB
20_large_20.txt AC 81 ms 2548 KB
20_large_21.txt AC 81 ms 2548 KB
20_large_22.txt AC 58 ms 2548 KB
20_large_23.txt AC 69 ms 2548 KB
20_large_24.txt AC 69 ms 2548 KB
20_large_25.txt WA 69 ms 2548 KB
20_large_26.txt AC 80 ms 2548 KB
20_large_27.txt AC 81 ms 2548 KB
20_large_28.txt WA 69 ms 2548 KB
20_large_29.txt AC 80 ms 2548 KB
20_large_30.txt AC 80 ms 2548 KB
30_run_through_01.txt WA 78 ms 2548 KB
70_maximum_01.txt AC 87 ms 2548 KB
80_hand_01.txt AC 34 ms 2548 KB
80_hand_02.txt AC 34 ms 2548 KB
80_hand_03.txt AC 34 ms 2548 KB
80_hand_04.txt WA 34 ms 2548 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 WA 1 ms 256 KB