https://www.acmicpc.net/problem/1977 import java.io.*;public class Main { static int N, M, total; static int min = Integer.MAX_VALUE; static int stoi(String s) { return Integer.parseInt(s); } public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); M = stoi(br.readLine()); N ..