diff --git a/packages/hydrojudge/src/cases.ts b/packages/hydrojudge/src/cases.ts index b9e614eb5..36d707166 100644 --- a/packages/hydrojudge/src/cases.ts +++ b/packages/hydrojudge/src/cases.ts @@ -14,11 +14,11 @@ function isValidConfig(config) { if (config.count > (getConfig('testcases_max') || 100)) { throw new FormatError('Too many testcases. Cancelled.'); } - const time = Math.sum(config.subtasks.map((subtask) => Math.sum(subtask.cases.map((c) => c.time)))); + const time = Math.sum(...config.subtasks.flatMap((subtask) => subtask.cases.map((c) => c.time))); if (time > (getConfig('total_time_limit') || 60) * 1000) { throw new FormatError('Total time limit longer than {0}s. Cancelled.', [+getConfig('total_time_limit') || 60]); } - const memMax = Math.max(config.subtasks.map((subtask) => Math.max(subtask.cases.map((c) => c.memory)))); + const memMax = Math.max(...config.subtasks.flatMap((subtask) => subtask.cases.map((c) => c.memory))); if (memMax > parseMemoryMB(getConfig('memoryMax'))) throw new FormatError('Memory limit larger than memory_max'); if (!['default', 'strict'].includes(config.checker_type || 'default') && !config.checker) { throw new FormatError('You did not specify a checker.');