Language: C

#include <stdio.h>
#include <stdlib.h>
#define KATA long/*型を入力して使うこと*/
void usort(KATA *a,KATA n){
    KATA *store;
    KATA hf=n,unit=1,a1,a2;
    store=malloc((KATA)sizeof(KATA)*n*2);
    for (int i=0;i<n;i++){
      store[i][0]=a[i][0];
      store[i][1]=a[i][1];
    }
    while (hf>1){
        if (hf==2){
            hf=(hf+1)/2;
            for (KATA i=0;i<hf;i++){
                a1=0;
                a2=0;
                while (a1+a2<2*unit && 2*i*unit+a1+a2<n){
                    if (a1==unit){
                        store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
                      store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
                        a2++;
                    }
                    else if (a2==unit || (2*i+1)*unit+a2==n){
                        store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
                      store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
                        a1++;
                    }
                    else if (a[(2*i+1)*unit+a2][0]>a[2*i*unit+a1][0]){
                        store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
                      store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
                        a1++;
                    }
                    else {
                        store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
                      store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
                        a2++;
                    }
                }
            }
            for (KATA i=0;i<n;i++) a[i]=store[i];
            break;
        }
        else if (hf%2){
            hf=(hf+1)/2;
            for (KATA i=0;i<hf-1;i++){
                a1=0;
                a2=0;
                while (a1+a2<2*unit && 2*i*unit+a1+a2<n){
                    if (a1==unit){
                        store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
                      store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
                        a2++;
                    }
                    else if (a2==unit || (2*i+1)*unit+a2==n){
                        store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
                      store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
                        a1++;
                    }
                    else if (a[(2*i+1)*unit+a2][0]>a[2*i*unit+a1][0]){
                        store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
                      store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
                        a1++;
                    }
                    else {
                        store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
                      store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
                        a2++;
                    }
                }
            }
        }
        else {
            hf=(hf+1)/2;
            for (KATA i=0;i<hf;i++){
                a1=0;
                a2=0;
                while (a1+a2<2*unit && 2*i*unit+a1+a2<n){
                    if (a1==unit){
                        store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
                      store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
                        a2++;
                    }
                    else if (a2==unit || (2*i+1)*unit+a2==n){
                        store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
                      store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
                        a1++;
                    }
                    else if (a[(2*i+1)*unit+a2][0]>a[2*i*unit+a1][0]){
                        store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
                      store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
                        a1++;
                    }
                    else {
                        store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
                      store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
                        a2++;
                    }
                }
            }
        }
        unit*=2;
        for (KATA i=0;i<n;i++) a[i]=store[i];
    }
    free(store);
    return;
}

int main(){
    KATA n,m,*d,cost=0;
    scanf("%lld%lld",&n,&m);
    d=malloc((KATA)sizeof(KATA)*n*2);
    for (KATA i=0;i<n;i++) scanf("%lld%lld",&d[i][0],&d[i][1]);
    usort(d,n);
    for (KATA i=0;i<n;i++){
      if (m>d[i][1]){
        cost+=d[i][0]*d[i][1];
        m-=d[i][1];
      }
      else {
        cost+=d[i][0]*m;
        break;
      }
    }
  printf("%lld\n",cost);
    free(d);
    return 0;
}


Compiler output:
main.c: In function 'usort':
main.c:9:15: error: subscripted value is neither array nor pointer nor vector
    9 |       store[i][0]=a[i][0];
      |               ^
main.c:9:23: error: subscripted value is neither array nor pointer nor vector
    9 |       store[i][0]=a[i][0];
      |                       ^
main.c:10:15: error: subscripted value is neither array nor pointer nor vector
   10 |       store[i][1]=a[i][1];
      |               ^
main.c:10:23: error: subscripted value is neither array nor pointer nor vector
   10 |       store[i][1]=a[i][1];
      |                       ^
main.c:20:46: error: subscripted value is neither array nor pointer nor vector
   20 |                         store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
      |                                              ^
main.c:20:68: error: subscripted value is neither array nor pointer nor vector
   20 |                         store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
      |                                                                    ^
main.c:21:44: error: subscripted value is neither array nor pointer nor vector
   21 |                       store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
      |                                            ^
main.c:21:66: error: subscripted value is neither array nor pointer nor vector
   21 |                       store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
      |                                                                  ^
main.c:25:46: error: subscripted value is neither array nor pointer nor vector
   25 |                         store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
      |                                              ^
main.c:25:64: error: subscripted value is neither array nor pointer nor vector
   25 |                         store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
      |                                                                ^
main.c:26:44: error: subscripted value is neither array nor pointer nor vector
   26 |                       store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
      |                                            ^
main.c:26:62: error: subscripted value is neither array nor pointer nor vector
   26 |                       store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
      |                                                              ^
main.c:29:48: error: subscripted value is neither array nor pointer nor vector
   29 |                     else if (a[(2*i+1)*unit+a2][0]>a[2*i*unit+a1][0]){
      |                                                ^
main.c:29:66: error: subscripted value is neither array nor pointer nor vector
   29 |                     else if (a[(2*i+1)*unit+a2][0]>a[2*i*unit+a1][0]){
      |                                                                  ^
main.c:30:46: error: subscripted value is neither array nor pointer nor vector
   30 |                         store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
      |                                              ^
main.c:30:64: error: subscripted value is neither array nor pointer nor vector
   30 |                         store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
      |                                                                ^
main.c:31:44: error: subscripted value is neither array nor pointer nor vector
   31 |                       store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
      |                                            ^
main.c:31:62: error: subscripted value is neither array nor pointer nor vector
   31 |                       store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
      |                                                              ^
main.c:35:46: error: subscripted value is neither array nor pointer nor vector
   35 |                         store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
      |                                              ^
main.c:35:68: error: subscripted value is neither array nor pointer nor vector
   35 |                         store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
      |                                                                    ^
main.c:36:44: error: subscripted value is neither array nor pointer nor vector
   36 |                       store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
      |                                            ^
main.c:36:66: error: subscripted value is neither array nor pointer nor vector
   36 |                       store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
      |                                                                  ^
main.c:51:46: error: subscripted value is neither array nor pointer nor vector
   51 |                         store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
      |                                              ^
main.c:51:68: error: subscripted value is neither array nor pointer nor vector
   51 |                         store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
      |                                                                    ^
main.c:52:44: error: subscripted value is neither array nor pointer nor vector
   52 |                       store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
      |                                            ^
main.c:52:66: error: subscripted value is neither array nor pointer nor vector
   52 |                       store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
      |                                                                  ^
main.c:56:46: error: subscripted value is neither array nor pointer nor vector
   56 |                         store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
      |                                              ^
main.c:56:64: error: subscripted value is neither array nor pointer nor vector
   56 |                         store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
      |                                                                ^
main.c:57:44: error: subscripted value is neither array nor pointer nor vector
   57 |                       store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
      |                                            ^
main.c:57:62: error: subscripted value is neither array nor pointer nor vector
   57 |                       store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
      |                                                              ^
main.c:60:48: error: subscripted value is neither array nor pointer nor vector
   60 |                     else if (a[(2*i+1)*unit+a2][0]>a[2*i*unit+a1][0]){
      |                                                ^
main.c:60:66: error: subscripted value is neither array nor pointer nor vector
   60 |                     else if (a[(2*i+1)*unit+a2][0]>a[2*i*unit+a1][0]){
      |                                                                  ^
main.c:61:46: error: subscripted value is neither array nor pointer nor vector
   61 |                         store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
      |                                              ^
main.c:61:64: error: subscripted value is neither array nor pointer nor vector
   61 |                         store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
      |                                                                ^
main.c:62:44: error: subscripted value is neither array nor pointer nor vector
   62 |                       store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
      |                                            ^
main.c:62:62: error: subscripted value is neither array nor pointer nor vector
   62 |                       store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
      |                                                              ^
main.c:66:46: error: subscripted value is neither array nor pointer nor vector
   66 |                         store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
      |                                              ^
main.c:66:68: error: subscripted value is neither array nor pointer nor vector
   66 |                         store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
      |                                                                    ^
main.c:67:44: error: subscripted value is neither array nor pointer nor vector
   67 |                       store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
      |                                            ^
main.c:67:66: error: subscripted value is neither array nor pointer nor vector
   67 |                       store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
      |                                                                  ^
main.c:80:46: error: subscripted value is neither array nor pointer nor vector
   80 |                         store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
      |                                              ^
main.c:80:68: error: subscripted value is neither array nor pointer nor vector
   80 |                         store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
      |                                                                    ^
main.c:81:44: error: subscripted value is neither array nor pointer nor vector
   81 |                       store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
      |                                            ^
main.c:81:66: error: subscripted value is neither array nor pointer nor vector
   81 |                       store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
      |                                                                  ^
main.c:85:46: error: subscripted value is neither array nor pointer nor vector
   85 |                         store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
      |                                              ^
main.c:85:64: error: subscripted value is neither array nor pointer nor vector
   85 |                         store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
      |                                                                ^
main.c:86:44: error: subscripted value is neither array nor pointer nor vector
   86 |                       store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
      |                                            ^
main.c:86:62: error: subscripted value is neither array nor pointer nor vector
   86 |                       store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
      |