```ts
export function parseAmount(text: string): number {
  if (typeof text !== 'string') throw new Error('Input must be a string');
  
  const match = text.match(/^\d+(\.\d{2})?$/);
  if (!match) throw new Error('Invalid amount format');

  const [_, integerPart, fractionalPart] = match;
  const cents = parseInt(integerPart || '0', 10) * 100 + (fractionalPart ? parseFloat(fractionalPart) * 100 : 0);

  if (isNaN(cents)) throw new Error('Invalid amount format');

  return cents;
}

export function formatAmount(cents: number): string {
  const integerPart = Math.floor(cents / 100);
  const fractionalPart = Math.round((cents % 100) * 100) / 100;

  return `${integerPart}.${fractionalPart.toFixed(2).padStart(3, '0')}`;
}

export function allocateCents(totalCents: number, weights: number[]): number[] {
  if (totalCents < 0 || !Number.isInteger(totalCents)) throw new Error('Total cents must be a non-negative integer');
  if (!Array.isArray(weights) || weights.some(weight => typeof weight !== 'number' || weight < 0 || !Number.isInteger(weight))) throw new Error('Weights must be non-negative integers');
  const totalWeight = weights.reduce((sum, weight) => sum + weight, 0);
  if (totalWeight === 0) throw new Error('Total weight cannot be zero');

  const shares: number[] = [];
  let remainingCents = totalCents;

  for (let i = 0; i < weights.length; i++) {
    const share = Math.floor(remainingCents / totalWeight);
    shares.push(share);
    remainingCents -= share;
    totalWeight -= weight;
  }

  // Distribute the leftover cents to the shares with the largest remainders
  let remainderIndex = 0;
  while (remainingCents > 0) {
    shares[remainderIndex] += 1;
    remainingCents--;
    remainderIndex = shares.reduce((maxIndex, share, index) => share > shares[maxIndex] ? index : maxIndex, 0);
  }

  return shares;
}
```