#include #include #include #include #include #include #include #include using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, c; cin >> n >> c; vector p(n); for (int i = 0; i < n; i++) { cin >> p[i]; } sort(p.begin(), p.end(), greater<>()); vector q[2]; for (int i = 0; i < c; i++) { int t, x; cin >> t >> x; q[t - 1].push_back(x); } for (int i = 0; i < 2; i++) { sort(q[i].begin(), q[i].end(), greater<>()); q[i].resize(n, 0); } constexpr int INF = 1 << 29; vector dp(n + 1, INF); dp[0] = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j >= 0; j--) { int j0 = j - 1; int j1 = i - j; int t0 = j0 >= 0 ? dp[j - 1] + max(p[i] - q[0][j0], 0) : INF; int t1 = j1 >= 0 ? dp[j] + p[i] / 100 * (100 - q[1][j1]) : INF; dp[j] = min(t0, t1); } } cout << *min_element(dp.begin(), dp.end()) << endl; return 0; }