Language: C

#include<stdio.h>
#include<stdlib.h>

void sort_a(int *array, int n);
void sort_bc(int *array_b,int *array_c, int n);

int main(){
    long int n, m;
    long int *a, *b, *c;
    int i,j;
    long int ans = 0;    
    a = (long int*)malloc(sizeof(long int)*n);
    b = (long int*)malloc(sizeof(long int)*m);
    c = (long int*)malloc(sizeof(long int)*m);

    
    scanf("%ld %ld", &n, &m);
    for(i=0;i<n;i++){
        scanf("%ld", &a[i]);
    }
    for(i=0;i<m;i++){
        scanf("%ld %ld", &b[i], &c[i]);
    }
    sort_a(a,n);
    sort_bc(b,c,m);
    
    /*
    for(i=0;i<n;i++){
        printf("%d:", a[i]);
    }
    printf("\n");

    for(i=0;i<m;i++){
        printf("%d:", b[i]);
    }
    printf("\n");

    for(i=0;i<m;i++){
        printf("%d:", c[i]);
    }
    printf("\n");
    */

    for(i=0; i<m; i++){
        for(j=0; j<b[i]; j++){
            if(a[j]<c[i]){
                a[j] = c[i];
            }
        }
        sort_a(a,n);
    }


    
    for(i=0;i<n;i++){
        //printf("%d:",a[i]);
        ans += a[i];
    }
    printf("%ld\n", ans);
    
    free(a);
    free(b);
    free(c);

    return 0;
}







void sort_a(int *array,long int n){
    int i,j;
    long int tmp;
    for(i=0; i<n; i++){
        for(j=0; j<n-1; j++){
            if(array[j]>array[j+1]){
                tmp = array[j+1];
                array[j+1] = array[j];
                array[j] = tmp;
            }
        }
    }
}

void sort_bc(long int *array_b, long int *array_c, int n){
    int i, j;
    long int tmp1, tmp2;
    for(i=0; i<n; i++){
        for(j=0; j<n-1; j++){
            if(array_c[j]>array_c[j+1]){
                tmp1 = array_c[j+1];
                array_c[j+1] = array_c[j];
                array_c[j] = tmp1;
                tmp2 = array_b[j+1];
                array_b[j+1] = array_b[j];
                array_b[j] = tmp2;
            }
        }
    }
}
    









Compiler output:
main.c: In function 'main':
main.c:24:12: error: passing argument 1 of 'sort_a' from incompatible pointer type [-Wincompatible-pointer-types]
   24 |     sort_a(a,n);
      |            ^
      |            |
      |            long int *
main.c:4:18: note: expected 'int *' but argument is of type 'long int *'
    4 | void sort_a(int *array, int n);
      |             ~~~~~^~~~~
main.c:25:13: error: passing argument 1 of 'sort_bc' from incompatible pointer type [-Wincompatible-pointer-types]
   25 |     sort_bc(b,c,m);
      |             ^
      |             |
      |             long int *
main.c:5:19: note: expected 'int *' but argument is of type 'long int *'
    5 | void sort_bc(int *array_b,int *array_c, int n);
      |              ~~~~~^~~~~~~
main.c:25:15: error: passing argument 2 of 'sort_bc' from incompatible pointer type [-Wincompatible-pointer-types]
   25 |     sort_bc(b,c,m);
      |               ^
      |               |
      |               long int *
main.c:5:32: note: expected 'int *' but argument is of type 'long int *'
    5 | void sort_bc(int *array_b,int *array_c, int n);
      |                           ~~~~~^~~~~~~
main.c:50:16: error: passing argument 1 of 'sort_a' from incompatible pointer type [-Wincompatible-pointer-types]
   50 |         sort_a(a,n);
      |                ^
      |                |
      |                long int *
main.c:4:18: note: expected 'int *' but argument is of type 'long int *'
    4 | void sort_a(int *array, int n);
      |             ~~~~~^~~~~
main.c: At top level:
main.c:74:6: error: conflicting types for 'sort_a'; have 'void(int *, long int)'
   74 | void sort_a(int *array,long int n){
      |      ^~~~~~
main.c:4:6: note: previous declaration of 'sort_a' with type 'void(int *, int)'
    4 | void sort_a(int *array, int n);
      |      ^~~~~~
main.c:88:6: error: conflicting types for 'sort_bc'; have 'void(long int *, long int *, int)'
   88 | void sort_bc(long int *array_b, long int *array_c, int n){
      |      ^~~~~~~
main.c:5:6: note: previous declaration of 'sort_bc' with type 'void(int *, int *, int)'
    5 | void sort_bc(int *array_b,int *array_c, int n);
      |      ^~~~~~~