import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int m = scanner.nextInt();
int n = scanner.nextInt();
int pkgPri [] = new int [n];
int onePri [] = new int [n];
int min;
for (int i = 0; i < n; i++) {
pkgPri[i] = scanner.nextInt();
onePri[i] = scanner.nextInt();
}
Arrays.sort(pkgPri);
Arrays.sort(onePri);
min = Math.min(((m/6)+1)*pkgPri[0], onePri[0]*m);
min = Math.min(min, ((m/6))*pkgPri[0] + (m%6)*onePri[0]);
System.out.println(min);
}
}
Test
'BOJ, Programmers' 카테고리의 다른 글
[JAVA] 백준 1041 (주사위) (0) | 2024.04.05 |
---|---|
[Java] 백준 1500 (최대곱) (0) | 2024.04.03 |
[Java] 백준 1010번 (다리놓기) (0) | 2024.03.30 |
[Java] 백준 1012번 (유기농 배추) (0) | 2024.03.30 |
[Java] 백준 1049 (좋은 구간) (1) | 2024.03.30 |