import java.io.*; /** * A master solution for Assessment Disruption. * It seems to produce the worse-case test, but I don't have a proof for it right now. * The test, assuming both objectives are minimised (which is later converted to what the problem wants), is: * 1 * 2 * 3 * . * . * ... w+2 w+1 w * * Assuming v=n-w, the number of comparisons runtime is: * w(w+1)/2 * v + v(v-1)/2 + w(w-1)/2 * which is maximised when v = n/3 rounded down. */ public class assessment_mb { private static final int MAX_WORD_COUNT = 10000; public static void main(String[] args) throws IOException { try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out)) { String test = in.readLine(); int wsIndex = test.indexOf(' '); int n = Integer.parseInt(test.substring(0, wsIndex)); int wordCount = Integer.parseInt(test.substring(wsIndex + 1)); int v = n / 3; int w = n - v; for (int i = 0; i < n; ++i) { int x = i < w ? v + i : n - 1 - i; int y = i < w ? n - v - 1 - i : 0; // x >= 0, being minimised, maps to word count being closest to wordCount // Note that the word count must never exceed 10000, so we choose the side wisely int myWordCount = wordCount + x <= MAX_WORD_COUNT ? wordCount + x : wordCount - x; // y >= 0, y <= n, being minimised, maps to quality maximized int quality = n - y; out.println(myWordCount + " " + quality); } } } }