rendered paste body/*ID: indy901PROG: gift1LANG: C*/#include <stdio.h>int NP;int i;int j;int amount;int people;int remain;int* accounts;int* spent;char* name;FILE* fp;char** names;int indexByName( char* theName ) { int k; int m; for ( k = 0; k < NP; k++ ) { for ( m = 0; m < 14; m++ ) { if ( !( names[ k ][ m ] == theName[ m ] ) ) break; return k; } }}int main() { fp = fopen( "gift1.in" , "r" ); fscanf( fp , "%d" , &NP ); for ( i < 0; i < NP; i++ ) accounts[ i ] = spent[ i ] = 0; names = ( char** )malloc( sizeof( char* ) * NP ); for ( i = 0; i < NP; i++ ) names[ i ] = ( char* )malloc( sizeof( char ) * 14 ); for ( i = 0; i < NP; i++ ) { for ( j = 0; j < NP; j++ ) names[ i ][ j ] = '\0'; } for ( i = 0; i < NP; i++ ) fscanf( fp , "%s" , names[ i ] ); for ( i = 0; i < NP; i++ ) { fscanf( fp , "%s" , &name ); fscanf( fp , "%d %d" , &amount , &people ); amount -= amount % people; spent[ indexByName( name ) ] += amount; for ( j = 0; j < people; j++ ) { fscanf( fp , "%s" &name ); accounts[ indexByName( name ) ] += amount / people; } } fclose( fp ); fp = fopen( "gift1.out" , "w" ); for ( i = 0; i < NP; i++ ) fprintf( fp , "%s %d\n" , names[ i ] , accounts[ i ] - spent[ i ] ); fclose( fp ); for ( i = 0; i < NP; i++ ) free( names[ i ] ); free( names ); return 0;}