```ts

export function parseAmount(text: string): number {
  if (typeof text !== 'string') {
    throw new Error('Input must be a string');
  }
  const [integerPart, fractionalPart] = text.split('.');
  if (!integerPart || !fractionalPart || fractionalPart.length !== 2) {
    throw new Error('Invalid amount format');
  }
  return parseInt(integerPart + fractionalPart, 10);
}

export function formatAmount(cents: number): string {
  const integerPart = Math.floor(cents / 100).toString();
  const fractionalPart = (cents % 100).toString().padStart(2, '0');
  return `${integerPart}.${fractionalPart}`;
}

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.length === 0) {
    throw new Error('Weights list cannot be empty');
  }

  // Validate each weight
  for (const weight of weights) {
    if (!Number.isInteger(weight) || weight < 0) {
      throw new Error('Each weight must be a non-negative integer');
    }
  }

  const totalWeight = weights.reduce((sum, weight) => sum + weight, 0);
  if (totalWeight === 0) {
    throw new Error('Total weights cannot sum to zero');
  }

  // Calculate the initial share size
  const shareSize = Math.floor(totalCents / totalWeight);

  // Distribute the leftover cents proportionally, largest remainder first
  let remainingCents = totalCents - (shareSize * totalWeight);
  const shares: number[] = weights.map(weight => {
    if (weight === 0) return 0;
    const share = Math.floor((totalCents * weight) / totalWeight);
    remainingCents -= share;
    return share;
  });

  // Distribute the leftover cents among the shares with the largest remainders
  let i = 0;
  while (remainingCents > 0) {
    if (i >= shares.length) break; // No more shares to distribute
    const remainder = remainingCents % weights[i];
    shares[i] += remainder;
    remainingCents -= remainder;
    i++;
  }

  return shares;
}
```