30802. Welcome Kit
Solutions
js
const testcases = [
{
input: '23\n3 1 4 1 5 9\n5 7',
output: '7\n3 2',
},
];
function solution(input) {
const inputParsed = input
.trim()
.split('\n')
.map(val => val.split(' ').map(Number));
let lineIdx = 0;
const [N] = inputParsed[lineIdx++];
const sizes = inputParsed[lineIdx++];
const [T, P] = inputParsed[lineIdx];
const result = [];
let tShirtsBundleCnt = 0;
sizes.forEach(size => {
tShirtsBundleCnt += Math.ceil(size / T);
});
result.push(tShirtsBundleCnt);
const penBundleCnt = Math.floor(N / P);
const penCnt = N % P;
result.push(`${penBundleCnt} ${penCnt}`);
return result.join('\n');
}
export default { solution, testcases };
js
const testcases = [
{
input: '23\n3 1 4 1 5 9\n5 7',
output: '7\n3 2',
},
];
function solution(input) {
const inputParsed = input
.trim()
.split('\n')
.map(val => val.split(' ').map(Number));
let lineIdx = 0;
const [N] = inputParsed[lineIdx++];
const sizes = inputParsed[lineIdx++];
const [T, P] = inputParsed[lineIdx];
const result = [];
let tShirtsBundleCnt = 0;
sizes.forEach(size => {
tShirtsBundleCnt += Math.ceil(size / T);
});
result.push(tShirtsBundleCnt);
const penBundleCnt = Math.floor(N / P);
const penCnt = N % P;
result.push(`${penBundleCnt} ${penCnt}`);
return result.join('\n');
}
module.exports = { solution, testcases };
ts
import type { Input, Output, Testcases } from 'bananass';
const testcases = [
{
input: '23\n3 1 4 1 5 9\n5 7',
output: '7\n3 2',
},
] satisfies Testcases;
function solution(input: Input): Output {
const inputParsed = input
.trim()
.split('\n')
.map(val => val.split(' ').map(Number));
let lineIdx = 0;
const [N] = inputParsed[lineIdx++];
const sizes = inputParsed[lineIdx++];
const [T, P] = inputParsed[lineIdx];
const result = [];
let tShirtsBundleCnt = 0;
sizes.forEach(size => {
tShirtsBundleCnt += Math.ceil(size / T);
});
result.push(tShirtsBundleCnt);
const penBundleCnt = Math.floor(N / P);
const penCnt = N % P;
result.push(`${penBundleCnt} ${penCnt}`);
return result.join('\n');
}
export default { solution, testcases };
ts
import type { Input, Output, Testcases } from 'bananass';
const testcases = [
{
input: '23\n3 1 4 1 5 9\n5 7',
output: '7\n3 2',
},
] satisfies Testcases;
function solution(input: Input): Output {
const inputParsed = input
.trim()
.split('\n')
.map(val => val.split(' ').map(Number));
let lineIdx = 0;
const [N] = inputParsed[lineIdx++];
const sizes = inputParsed[lineIdx++];
const [T, P] = inputParsed[lineIdx];
const result = [];
let tShirtsBundleCnt = 0;
sizes.forEach(size => {
tShirtsBundleCnt += Math.ceil(size / T);
});
result.push(tShirtsBundleCnt);
const penBundleCnt = Math.floor(N / P);
const penCnt = N % P;
result.push(`${penBundleCnt} ${penCnt}`);
return result.join('\n');
}
module.exports = { solution, testcases };
Explanation
Number of T-shirt Bundles
The number of bundles required for each T-shirt size is as follows:
Number of Pen Bundles and Loose Pens
Total number of participants:
Exactly
- Maximum number of pen bundles:
- Number of individual pens: