/* * Solution Template for TSP * * Australian Informatics Olympiad 2022 * * This file is provided to assist with reading and writing of the input * files for the problem. You may modify this file however you wish, or * you may choose not to use this file at all. */ import java.io.*; class Solution { /* N is the number of days. */ private static int N; /* L contains the minimum number of tomatoes you must sell each day. */ private static int L[] = new int[100005]; /* R contains the maximum number of tomatoes you must sell each day. */ private static int R[] = new int[100005]; /* * Read the next token from the input file. * Tokens are separated by whitespace, i.e., spaces, tabs and newlines. * If end-of-file is reached then an empty string is returned. */ private static String readToken(BufferedReader in) throws IOException { StringBuffer ans = new StringBuffer(); int next; /* Skip any initial whitespace. */ next = in.read(); while (next >= 0 && Character.isWhitespace((char)next)) next = in.read(); /* Read the following token. */ while (next >= 0 && ! Character.isWhitespace((char)next)) { ans.append((char)next); next = in.read(); } return ans.toString(); } public static void main(String[] args) throws IOException { /* Open the input and output files. */ BufferedReader input_file = new BufferedReader(new FileReader( "tspin.txt")); BufferedWriter output_file = new BufferedWriter(new FileWriter( "tspout.txt")); /* Read the value of N. */ N = Integer.parseInt(readToken(input_file)); /* Read the values of L and R. */ for (int i = 0; i < N; i++) { L[i] = Integer.parseInt(readToken(input_file)); } for (int i = 0; i < N; i++) { R[i] = Integer.parseInt(readToken(input_file)); } /* * TODO: This is where you should compute your solution. You should * output YES or NO depending on whether it is possible to meet the * requirements. An example of how to output YES is shown below. */ output_file.write("YES\n"); /* Finally, close the input/output files. */ input_file.close(); output_file.close(); } }