Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <fstream>

using namespace std;


struct Magic{
	string name;
	int mp;
	bool isAll;
	int dmg;
};

int n;
int hps[101];
int m;
Magic magics[101];
const ll INF=100000000000000LL;

// SÌÉ é_[Wð^¦éÌÉKvÈÅ¬ÌMP(¶ÝµÈ¯êÎ-1)
ll dp[2][200001];
// PÌÉ é_[Wð^¦éÌÉKvÈÅ¬MP(¿å¤ÇÌ_[WÅÈ­Äàæ¢
ll dp2[2][200001];

int main(){
	while(cin>>n&&n){
		vector<Magic> allMagics;
		vector<Magic> singleMagics;
		vector<Magic> crit;
		for(int i=0;i<n;i++)cin>>hps[i];
		cin>>m;
		for(int i=0;i<m;i++){
			cin>>magics[i].name>>magics[i].mp;
			string tgt;
			cin>>tgt;
			if(tgt=="All")magics[i].isAll=true;
			else magics[i].isAll=false;
			cin>>magics[i].dmg;
			if(magics[i].dmg==0)continue;
			else if(magics[i].isAll){
				// 100000ÈãÌêAêKE
				if(magics[i].dmg>=100000)crit.push_back(magics[i]);
				else allMagics.push_back(magics[i]);
			}
			else singleMagics.push_back(magics[i]);
		}
		ll minMP=INF;
		// êKE
		for(int i=0;i<(int)crit.size();i++)minMP=min(minMP,crit[i].mp*1LL);
		for(int i=0;i<2;i++)for(int j=0;j<=200000;j++)dp[i][j]=dp2[i][j]=INF;
		dp[(allMagics.size())%2][0]=0;
		dp2[(singleMagics.size())%2][0]=0;
		for(int i=allMagics.size()-1;i>=0;i--){
			for(int j=0;j<=200000;j++){
				int dmg=j;
				int pos=i;
				ll res=INF;
				int cur=(i+1)%2;
				int nxt=i%2;
				res=min(res,dp[cur][dmg]);
				// ¿å¤Ç0ÉÈéKvª é
				if(dmg-allMagics[pos].dmg>=0)
					res=min(res,dp[nxt][dmg-allMagics[pos].dmg]+allMagics[pos].mp);
				dp[nxt][dmg]=res;
			}
		}
		for(int i=singleMagics.size()-1;i>=0;i--){
			for(int j=0;j<=200000;j++){
				int dmg=j;
				int pos=i;
				ll res=INF;
				int cur=(i+1)%2;
				int nxt=i%2;
				res=min(res,dp2[cur][dmg]);
				if(dmg-singleMagics[pos].dmg>=0)
					res=min(res,dp2[nxt][dmg-singleMagics[pos].dmg]+singleMagics[pos].mp);
				// KvÈÌÍ¡ñÌªÌÝ
				else res=min(res,singleMagics[pos].mp*1LL);
				dp2[nxt][dmg]=res;
			}
		}
		// SÌÉ^¦é_[WÊðvZ
		for(int i=0;i<=200000;i++){
			if(dp[0][i]==INF)continue;
			ll cnt=0;
			for(int j=0;j<n;j++){
				int a=hps[j]-i;
				if(a>0)cnt+=dp2[0][a];
			}
			minMP=min(minMP,cnt+dp[0][i]);
		}
		cout<<minMP<<endl;
	}
	return 0;
}

Compiler output:
a.cc:22:7: error: 'll' does not name a type
   22 | const ll INF=100000000000000LL;
      |       ^~
a.cc:25:1: error: 'll' does not name a type
   25 | ll dp[2][200001];
      | ^~
a.cc:27:1: error: 'll' does not name a type
   27 | ll dp2[2][200001];
      | ^~
a.cc: In function 'int main()':
a.cc:51:17: error: 'll' was not declared in this scope
   51 |                 ll minMP=INF;
      |                 ^~
a.cc:53:52: error: 'minMP' was not declared in this scope
   53 |                 for(int i=0;i<(int)crit.size();i++)minMP=min(minMP,crit[i].mp*1LL);
      |                                                    ^~~~~
a.cc:54:63: error: 'dp' was not declared in this scope
   54 |                 for(int i=0;i<2;i++)for(int j=0;j<=200000;j++)dp[i][j]=dp2[i][j]=INF;
      |                                                               ^~
a.cc:54:72: error: 'dp2' was not declared in this scope
   54 |                 for(int i=0;i<2;i++)for(int j=0;j<=200000;j++)dp[i][j]=dp2[i][j]=INF;
      |                                                                        ^~~
a.cc:54:82: error: 'INF' was not declared in this scope
   54 |                 for(int i=0;i<2;i++)for(int j=0;j<=200000;j++)dp[i][j]=dp2[i][j]=INF;
      |                                                                                  ^~~
a.cc:55:17: error: 'dp' was not declared in this scope
   55 |                 dp[(allMagics.size())%2][0]=0;
      |                 ^~
a.cc:56:17: error: 'dp2' was not declared in this scope
   56 |                 dp2[(singleMagics.size())%2][0]=0;
      |                 ^~~
a.cc:61:35: error: expected ';' before 'res'
   61 |                                 ll res=INF;
      |                                   ^~~~
      |                                   ;
a.cc:64:33: error: 'res' was not declared in this scope
   64 |                                 res=min(res,dp[cur][dmg]);
      |                                 ^~~
a.cc:75:35: error: expected ';' before 'res'
   75 |                                 ll res=INF;
      |                                   ^~~~
      |                                   ;
a.cc:78:33: error: 'res' was not declared in this scope
   78 |                                 res=min(res,dp2[cur][dmg]);
      |                                 ^~~
a.cc:88:38: error: 'INF' was not declared in this scope
   88 |                         if(dp[0][i]==INF)continue;
      |                                      ^~~
a.cc:89:27: error: expected ';' before 'cnt'
   89 |                         ll cnt=0;
      |                           ^~~~
      |                           ;
a.cc:92:40: error: 'cnt' was not declared in this scope; did you mean 'int'?
   92 |                                 if(a>0)cnt+=dp2[0][a];
      |                                        ^~~
      |                                        int
a.cc:94:25: error: 'minMP' was not declared in this scope
   94 |                         minMP=min(minMP,cnt+dp[0][i]);
      |                         ^~~~~
a.cc:94:41: error: 'cnt' was not declared in this scope; did you mean 'int'?
   94 |                         minMP=min(minMP,cnt+dp[0][i]);
      |                                         ^~~
      |                                         int
a.cc:96:23: error: 'minMP' was not declared in this scope
   96 |                 cout<<minMP<<endl;
      |                       ^~~~~