/* * Solution Template for Wheeling and Dealing * * Australian Informatics Olympiad 2023 * * This file is provided to assist with reading and writing of the input * files for the problem. You may modify this file however you wish, or * you may choose not to use this file at all. */ #include /* N is the number of candidates. */ int N; /* M is the number of voters. */ int M; /* * V contains the voters plans. Note that here the voters are numbered starting * from 0. */ int V[100005]; /* * P contains the amount of money that you can pay each voter to change their * vote. Note that here the voters are numbered starting from 0. */ int P[100005]; int answer; int main(void) { FILE *input_file; FILE *output_file; int i; /* Open the input and output files. */ input_file = fopen("dealin.txt", "r"); output_file = fopen("dealout.txt", "w"); /* Read the values of N, M, V and P from input file. */ fscanf(input_file, "%d%d", &N, &M); for (i = 0; i < M; i++) { fscanf(input_file, "%d", &V[i]); } for (i = 0; i < M; i++) { fscanf(input_file, "%d", &P[i]); } /* * TODO: This is where you should compute your solution. Store the minimum * amount of money that you must pay so that candidate 1 wins into the * variable answer. */ /* Write the answers to the output file. */ fprintf(output_file, "%d\n", answer); /* Finally, close the input/output files. */ fclose(input_file); fclose(output_file); return 0; }