#include #include #include #include #include #include #include #include #include static const int MOD = 1000000007; using ll = long long; using u32 = unsigned; using u64 = unsigned long long; using namespace std; template constexpr T INF = ::numeric_limits::max() / 32 * 15 + 208; template vector make_v(U size, const T& init){ return vector(static_cast(size), init); } template auto make_v(U size, Ts... rest) { return vector(static_cast(size), make_v(rest...)); } template void chmin(T &a, const T &b){ a = (a < b ? a : b); } template void chmax(T &a, const T &b){ a = (a > b ? a : b); } int main() { int n, c; cin >> n >> c; vector p(n); for (auto &&i : p) scanf("%d", &i); sort(p.begin(),p.end(), greater<>()); vector T1, T2; for (int i = 0; i < c; ++i) { int t, x; cin >> t >> x; if(t == 1) T1.emplace_back(x); else T2.emplace_back(x); } sort(T1.begin(),T1.end(), greater<>()); sort(T2.begin(),T2.end(), greater<>()); auto dp = make_v(T1.size()+1, T2.size()+1, INF); dp[0][0] = 0; int ans = INF; for (int i = 0; i <= T1.size(); ++i) { for (int j = 0; j <= T2.size(); ++j) { if(i+j > n) continue; if(i) chmin(dp[i][j], dp[i-1][j]+max(p[i+j-1]-T1[i-1], 0)); if(j) chmin(dp[i][j], dp[i][j-1]+p[i+j-1]/100*(100-T2[j-1])); if(i+j == n) chmin(ans, dp[i][j]); } } int val = 0; for (int i = c; i < n; ++i) { val += p[i]; } cout << min(ans, dp.back().back()+val) << "\n"; return 0; }