import java.util.Scanner; import java.util.List; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; public class No1430 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int C = scan.nextInt(); List P = new ArrayList(); for (int i=0; i < N; i++) { P.add(scan.nextInt()); } Collections.sort(P, Collections.reverseOrder()); List TY = new ArrayList(); List TP = new ArrayList(); for (int i=0; i < C; i++) { int T = scan.nextInt(); int X = scan.nextInt(); if (T == 1) { TY.add(X); } else { TP.add(X); } } scan.close(); Collections.sort(TY, Collections.reverseOrder()); Collections.sort(TP, Collections.reverseOrder()); int L = TY.size(); int[][] DP = new int[N+1][L+1]; for (int i=0; i <= N; i++) { Arrays.fill(DP[i], Integer.MAX_VALUE); } DP[0][0] = 0; for (int i=0; i < N; i++) { for (int j=0; j <= L; j++) { int price = P.get(i); int cost; if (i-j < 0) { cost = 0; } else if (i-j < TP.size()) { cost = price * (100 - TP.get(i-j)) / 100; } else { cost = price; } DP[i+1][j] = Math.min(DP[i+1][j], DP[i][j] + cost); if (j < L) { cost = price - Math.min(price, TY.get(j)); DP[i+1][j+1] = Math.min(DP[i+1][j+1], DP[i][j] + cost); } } } int min = Integer.MAX_VALUE; for (int j=0; j <=L; j++) { min = Math.min(min, DP[N][j]); } System.out.println(min); } }