Language: C++

#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {

  char str[20];
  int t[110];
  int p[110];
  int q[110];
  int c[110];
  int dp[2][110000];
      int a;
        while(cin >> a && a) { //N(??¢?????????????????°)???????????????

                //N???????????¢???????????????HP(??????)???????????????
                for(int i=0; i<a; i++) cin >> c[i];
                int b;
                cin >> b; //M(????????????????????°)???????????????
                //Name(???????????????), MP(?¶????MP), Target(Single or All), Damage(????????????????????????)???????????????
                for(int i=0; i<b; i++) {
                        cin >> str >> p[i] >> str >> q[i]; //???????????????????????????Name???????????????????????????
                        if(str[0]=='S') t[i]=1;
                        else t[i]=0;
                }

                //????????? dp[Single -> 1 or All -> 0][????¨?????????????] = ????¨??¶????MP
                for(int i=0; i<110000; i++) dp[0][i]=dp[1][i]=1999999999;
                dp[0][0]=dp[1][0]=0;
                for(int i=0; i<b; i++) {
                        for(int j=0; j<110000; j++) {
                                /**
                                  * min??§109999??¨???????????????100000??\?????§????????°?????¢???????????????????????§????????????????????????
                                  * ?????????????????????(???????????????j+i?????????????????????????????????)?????¨??????MP?¶????????????¨
                                  * (????????????j?????¨??????MP?¶???????+i??????????????????MP?¶???????)?????????
                                  * ????????????i????????????????????????????????¨?????????MP?¶???????????°????????????°???
                                  * ????????????????¶????MP???????´??????????
                                **/
                                dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
                        }
                }

                //??????????????¨??¨????????????????????§?????????????????????????????????????°?MP??????????±??????????
                for(int i=109998; i>=0; i--) {
                        dp[0][i]=min(dp[0][i],dp[0][i+1]);
                        dp[1][i]=min(dp[1][i],dp[1][i+1]);
                }

                /**
                  * ????????¢????????????1????????????????????¨????????????
                  *
                **/
                long long ret=1999999999;
                for(int i=0; i<110000; i++) {
                        long long val=dp[0][i];
                        for(int j=0; j<a; j++) {
                                if(i>=c[j]) continue; //????????¢??????????????????????????????i(?????????????????????)?????§????????´???(???????????´??????)?????????????????????
                                val+=dp[1][c[j]-i]; //?????£?????????????????????????????§????????¨????????????????°?MP???val????¶???????
                        }
                        ret=min(ret,val);???//???????¶??????????MP????°????????????????????´?
                }
                cout << ret << endl;
        }
}

Compiler output:
a.cc:40:121: warning: trigraph ??) ignored, use -trigraphs to enable [-Wtrigraphs]
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
a.cc:61:43: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]
   61 |                         ret=min(ret,val);???//???????¶??????????MP????°????????????????????´?
a.cc: In function 'int main()':
a.cc:40:66: error: expected primary-expression before '?' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                  ^
a.cc:40:67: error: expected primary-expression before '?' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                   ^
a.cc:40:68: error: expected primary-expression before '?' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                    ^
a.cc:40:89: error: expected primary-expression before '?' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                                         ^
a.cc:40:90: error: expected primary-expression before '?' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                                          ^
a.cc:40:91: error: expected primary-expression before '?' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                                           ^
a.cc:40:98: error: expected ':' before ')' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                                                  ^
      |                                                                                                  :
a.cc:40:98: error: expected primary-expression before ')' token
a.cc:40:98: error: expected ':' before ')' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                                                  ^
      |                                                                                                  :
a.cc:40:98: error: expected primary-expression before ')' token
a.cc:40:98: error: expected ':' before ')' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                                                  ^
      |                                                                                                  :
a.cc:40:98: error: expected primary-expression before ')' token
a.cc:40:101: error: expected primary-expression before '?' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                                                     ^
a.cc:40:102: error: expected primary-expression before '?' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                                                      ^
a.cc:40:103: error: expected primary-expression before '?' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                                                       ^
a.cc:40:121: error: expected primary-expression before '?' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                                                                         ^
a.cc:40:122: error: expected primary-expression before '?' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                                                                          ^
a.cc:40:123: error: expected primary-expression before ')' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                                                                           ^
a.cc:40:123: error: expected ':' before ')' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                                                                           ^
      |                                                                                                                           :
a.cc:40:123: error: expected primary-expression before ')' token
a.cc:40:123: error: expected ':' before ')' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                                                                           ^
      |                                                                                                                           :
a.cc:40:123: error: expected primary-expression before ')' token
a.cc:40:123: error: expected ':' before ')' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                                                                           ^
      |                                                                                                                           :
a.cc:40:123: error: expected primary-expression before ')' token
a.cc:40:123: error: expected ':' before ')' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                                                                           ^
      |                                                                                                                           :
a.cc:40:123: error: expected primary-expression before ')' token
a.cc:40:123: error: expected ':' before ')' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                                                                           ^
      |                                                                                                                           :
a.cc:40:123: error: expected primary-expression before ')' token
a.cc:40:123: error: expected ':' before ')' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                                                                           ^
      |                                                                                                                           :
a.cc:40:123: error: expected primary-expression before ')' token
a.cc:40:123: error: expected ':' before ')' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                                                                           ^
      |                                                                                                                           :
a.cc:40:123: error: expected primary-expression before ')' token
a.cc:40:123: error: expected ':' before ')' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                                                                           ^
      |                                                                                                                           :
a.cc:40:123: error: expected primary-expression before ')' token
a.cc:40:123: error: expected ':' before ')' token
   40 |                                 dp[t[i]][min(109999,j+q[i])]=min(???dp[t[i]][min(109999,???j+q[i])],???dp[t[i]][j]+p[i]???);
      |                                                                                                                           ^
      |                                                                                                                           :
a.cc:40:123: error: expected primary-expression before ')' token
a.cc:61:42: error: expected primary-expression before '?' token
   61 |                         ret=min(ret,val);???//???????¶??????????MP????°????????????????????´?
      |