Submission #57709569


Source Code Expand

Copy
#include <stdio.h>
#include <inttypes.h>
int N;
int A[212345];
uint64_t memo[212345][2];
uint64_t calc(int pos, int next_bonus) {
uint64_t ans, candidate;
if (pos >= N) return 0;
if (memo[pos][next_bonus]) return ~memo[pos][next_bonus];
ans = calc(pos + 1, next_bonus);
candidate = calc(pos + 1, !next_bonus) + (uint64_t)A[pos] * (next_bonus + 1);
if (candidate > ans) ans = candidate;
return ~(memo[pos][next_bonus] = ~ans);
}
int main(void) {
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <stdio.h>
#include <inttypes.h>

int N;
int A[212345];

uint64_t memo[212345][2];

uint64_t calc(int pos, int next_bonus) {
	uint64_t ans, candidate;
	if (pos >= N) return 0;
	if (memo[pos][next_bonus]) return ~memo[pos][next_bonus];

	ans = calc(pos + 1, next_bonus);
	candidate = calc(pos + 1, !next_bonus) + (uint64_t)A[pos] * (next_bonus + 1);
	if (candidate > ans) ans = candidate;

	return ~(memo[pos][next_bonus] = ~ans);
}

int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	printf("%" PRIu64 "\n", calc(0, 0));
	return 0;
}

Submission Info

Submission Time
Task D - Bonus EXP
User mikecat
Language C (gcc 12.2.0)
Score 400
Code Size 654 Byte
Status AC
Exec Time 31 ms
Memory 18140 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 49
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, random_33.txt, random_34.txt, random_35.txt, random_36.txt, random_37.txt, random_38.txt, random_39.txt
Case Name Status Exec Time Memory
example_00.txt AC 0 ms 1628 KB
example_01.txt AC 1 ms 1716 KB
hand_00.txt AC 21 ms 18128 KB
hand_01.txt AC 24 ms 17992 KB
hand_02.txt AC 0 ms 1628 KB
hand_03.txt AC 22 ms 17996 KB
hand_04.txt AC 23 ms 17992 KB
hand_05.txt AC 24 ms 18028 KB
hand_06.txt AC 0 ms 1620 KB
random_00.txt AC 22 ms 18012 KB
random_01.txt AC 25 ms 18028 KB
random_02.txt AC 22 ms 17972 KB
random_03.txt AC 22 ms 18020 KB
random_04.txt AC 28 ms 18124 KB
random_05.txt AC 31 ms 18020 KB
random_06.txt AC 23 ms 18024 KB
random_07.txt AC 26 ms 18108 KB
random_08.txt AC 21 ms 17964 KB
random_09.txt AC 30 ms 17992 KB
random_10.txt AC 26 ms 17996 KB
random_11.txt AC 19 ms 18140 KB
random_12.txt AC 24 ms 18040 KB
random_13.txt AC 22 ms 17992 KB
random_14.txt AC 28 ms 18120 KB
random_15.txt AC 27 ms 18108 KB
random_16.txt AC 31 ms 18016 KB
random_17.txt AC 28 ms 18128 KB
random_18.txt AC 21 ms 18128 KB
random_19.txt AC 24 ms 17956 KB
random_20.txt AC 25 ms 17968 KB
random_21.txt AC 29 ms 18136 KB
random_22.txt AC 26 ms 18016 KB
random_23.txt AC 25 ms 18104 KB
random_24.txt AC 27 ms 18016 KB
random_25.txt AC 27 ms 18124 KB
random_26.txt AC 27 ms 18140 KB
random_27.txt AC 27 ms 18132 KB
random_28.txt AC 27 ms 18108 KB
random_29.txt AC 27 ms 18020 KB
random_30.txt AC 31 ms 18036 KB
random_31.txt AC 31 ms 17996 KB
random_32.txt AC 31 ms 17972 KB
random_33.txt AC 31 ms 17960 KB
random_34.txt AC 31 ms 17988 KB
random_35.txt AC 31 ms 18020 KB
random_36.txt AC 31 ms 17972 KB
random_37.txt AC 31 ms 17968 KB
random_38.txt AC 31 ms 17956 KB
random_39.txt AC 31 ms 18116 KB


2024-09-15 (Sun)
08:41:22 +09:00