#define _USE_MATH_DEFINES #include using namespace std; //template #define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define ALL(v) (v).begin(),(v).end() using ll=long long int; const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12; templateinline bool chmax(T& a,T b){if(ainline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;} //end int main(){ int n,c; cin>>n>>c; vector p(n); rep(i,0,n)cin>>p[i]; using P=array; vector

cs(c); rep(i,0,c)cin>>cs[i][0]>>cs[i][1]; sort(ALL(p),greater()); bitset<5010> used; ll res=0; rep(i,0,n){ int add=p[i],id; rep(j,0,c)if(!used[j]){ int sub; if(cs[j][0]==1)sub=max(0,p[i]-cs[j][1]); else sub=p[i]/100*(100-cs[j][1]); if(chmin(add,sub))id=j; } used[id]=1; res+=add; } cout<