summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AlgoDesignAndTechniqueEdxJava/sources/MaxPairProduct.java35
1 files changed, 31 insertions, 4 deletions
diff --git a/AlgoDesignAndTechniqueEdxJava/sources/MaxPairProduct.java b/AlgoDesignAndTechniqueEdxJava/sources/MaxPairProduct.java
index 18b9521..dbe4ee6 100644
--- a/AlgoDesignAndTechniqueEdxJava/sources/MaxPairProduct.java
+++ b/AlgoDesignAndTechniqueEdxJava/sources/MaxPairProduct.java
@@ -1,4 +1,5 @@
-import java.util.Scanner;
+import java.io.*;
+import java.util.*;
public class MaxPairProduct {
int numberOfIntegers;
@@ -14,7 +15,7 @@ public class MaxPairProduct {
}
public static void main(String[] args) {
- Scanner s = new Scanner(System.in);
+ FastScanner s = new FastScanner(System.in);
int n = s.nextInt();
MaxPairProduct mpp = new MaxPairProduct(n);
@@ -22,8 +23,6 @@ public class MaxPairProduct {
mpp.newNumber(s.nextInt());
}
- s.close();
-
System.out.println(mpp.getProduct());
}
@@ -57,3 +56,31 @@ public class MaxPairProduct {
}
}
+
+final class FastScanner {
+ BufferedReader br;
+ StringTokenizer st;
+
+ FastScanner(InputStream stream) {
+ try {
+ br = new BufferedReader(new InputStreamReader(stream));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ String next() {
+ while (st == null || !st.hasMoreTokens()) {
+ try {
+ st = new StringTokenizer(br.readLine());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ return st.nextToken();
+ }
+
+ int nextInt() {
+ return Integer.parseInt(next());
+ }
+} \ No newline at end of file