#include "bits/stdc++.h" //#include "atcoder/all" using namespace std; //using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; //const int INF = 1e9; //const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n-1); i >= 0; --i) #define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define endl "\n" int dp[5001][5001]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, C; cin >> N >> C; vectorP(N); int sum = 0; rep(i, N) { cin >> P[i]; sum += P[i]; } sort(allR(P)); vector C1; vector C2; rep(i, C) { int t, x; cin >> t >> x; if (1 == t) { C1.push_back(x); } else { C2.push_back(x); } } sort(allR(C1)); sort(allR(C2)); dp[0][0] = 0; rep(i, C1.size() + 1) { rep(j, C2.size() + 1) { if ((i + j + 1) > N) { //商品がない dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]); dp[i][j + 1] = max(dp[i][j + 1], dp[i][j]); continue; } { if (i < C1.size()) { int v = max(0, P[i + j] - C1[i]); dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + P[i + j] - v); } else { dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]); } } { if (j < C2.size()) { int v = P[i + j] * (100 - C2[j]) / 100; dp[i][j + 1] = max(dp[i][j + 1], dp[i][j] + P[i + j] - v); } else { dp[i][j + 1] = max(dp[i][j + 1], dp[i][j]); } } } } cout << sum - dp[C1.size()][C2.size()] << endl; return 0; }