#include using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, c, t, x; cin >> n >> c; vector p(n); vector> tb(2, vector(n)); for(auto &&v : p) cin >> v; for(int i = 0, j = 0, k = 0; i < c; i++){ cin >> t >> x; tb[--t][t ? j++ : k++] = x; } sort(tb[0].rbegin(), tb[0].rend()); sort(tb[1].rbegin(), tb[1].rend()); sort(p.rbegin(), p.rend()); vector> dp(n + 1, vector(n + 1, 1 << 30)); dp[0][0] = 0; for(int i = 0; i < n; i++){ for(int j = 0; j <= i; j++){ int k = i - j; dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + p[i] / 100 * (100 - tb[1][k])); dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + max(0, p[i] - tb[0][j])); } } cout << *min_element(dp[n].begin(), dp[n].end()) << '\n'; }