content stringlengths 219 31.2k | complexity stringclasses 5
values | file_name stringlengths 6 9 | complexity_ranked float64 0.1 0.9 |
|---|---|---|---|
// Java program to find maximum pair sum whose
// difference is less than K
import
java.io.*;
import
java.util.*;
class
GFG {
// method to return maximum sum we can get by
// finding less than K difference pair
static
int
maxSumPairWithDifferenceLessThanK(
int
arr[],
int
N,
int
K)
{
// Sort input ... | nlogn | 326.java | 0.7 |
// Java program to find maximum pair sum whose
// difference is less than K
import
java.io.*;
import
java .util.*;
class
GFG {
// Method to return maximum sum we can get by
// finding less than K difference pairs
static
int
maxSumPairWithDifferenceLessThanK(
int
arr[],
int
N,
int
k)
{
int
maxSum = ... | nlogn | 327.java | 0.7 |
// Java code for kth smallest element
// in an array
import
java.util.Arrays;
import
java.util.Collections;
class
GFG
{
// Function to return k'th smallest
// element in a given array
public
static
int
kthSmallest(Integer [] arr,
int
k)
{
// Sort the given array
Arrays.sort(arr);
// Return k'th ... | nlogn | 41.java | 0.7 |
// Java code to calculate maximum unique
// element of every segment of array
import
java.io.*;
import
java.util.*;
class
GFG {
static
void
find_max(
int
[] A,
int
N,
int
K)
{
// Storing counts of first K-1 elements
// Also storing distinct elements.
HashMap<Integer, Integer> Count =
new
HashMap<>();... | nlogn | 450.java | 0.7 |
// Java program to find number of pairs
// and minimal possible value
import
java.util.*;
class
GFG {
// function for finding pairs and min value
static
void
pairs(
int
arr[],
int
n,
int
k)
{
// initialize smallest and count
int
smallest = Integer.MAX_VALUE;
int
count=
0
;
// iterate over all pai... | nlogn | 457.java | 0.7 |
// The following implementation assumes that the activities
// are already sorted according to their finish time
import
java.util.*;
import
java.lang.*;
import
java.io.*;
class
ActivitySelection
{
// Prints a maximum set of activities that can be done by a single
// person, one at a time.
// n --> Total n... | nlogn | 458.java | 0.7 |
// Java program to find the maximum profit job sequence
// from a given array of jobs with deadlines and profits
import
java.util.*;
// A Simple Disjoint Set Data Structure
class
DisjointSet
{
int
parent[];
// Constructor
DisjointSet(
int
n)
{
parent =
new
int
[n +
1
];
// Every node is a parent ... | nlogn | 459.java | 0.7 |
// Java code to find largest
// three elements in an array
import
java.io.*;
import
java.util.Arrays;
class
GFG {
void
find3largest(
int
[] arr)
{
Arrays.sort(arr);
//It uses Tuned Quicksort with
//avg. case Time complexity = O(nLogn)
int
n = arr.length;
int
check =
0
, count =
1
;
for
(
int
i... | nlogn | 46.java | 0.7 |
import
java.util.PriorityQueue;
import
java.util.Scanner;
import
java.util.Comparator;
// node class is the basic structure
// of each node present in the Huffman - tree.
class
HuffmanNode {
int
data;
char
c;
HuffmanNode left;
HuffmanNode right;
}
// comparator class helps to compare the node
// on... | nlogn | 460.java | 0.7 |
// Java program for Kruskal's algorithm to find Minimum
// Spanning Tree of a given connected, undirected and
// weighted graph
import
java.util.*;
import
java.lang.*;
import
java.io.*;
class
Graph
{
// A class to represent a graph edge
class
Edge
implements
Comparable<Edge>
{
int
src, dest, weight;
... | nlogn | 464.java | 0.7 |
// Java program for Prim's MST for
// adjacency list representation of graph
import
java.util.LinkedList;
import
java.util.TreeSet;
import
java.util.Comparator;
public
class
prims {
class
node1 {
// Stores destination vertex in adjacency list
int
dest;
// Stores weight of a vertex in the adjacency list... | nlogn | 466.java | 0.7 |
// Java implementation of
// above algorithm
import
java.io.*;
import
java.util.*;
public
class
GFG {
static
int
MaxSumDifference(Integer []a,
int
n)
{
// final sequence stored in the vector
List<Integer> finalSequence =
new
ArrayList<Integer>();
// sort the original array
// so that we can retr... | nlogn | 474.java | 0.7 |
// Java program to maximize the sum of difference
// between consecutive elements in circular array
import
java.io.*;
import
java.util.Arrays;
class
MaxSum
{
// Return the maximum Sum of difference between
// consecutive elements.
static
int
maxSum(
int
arr[],
int
n)
{
int
sum =
0
;
// Sorting the... | nlogn | 475.java | 0.7 |
// Java program to find maximum height pyramid
// from the given object width.
import
java.io.*;
import
java.util.Arrays;
class
GFG {
// Returns maximum number of pyramidcal
// levels n boxes of given widths.
static
int
maxLevel(
int
[]boxes,
int
n)
{
// Sort objects in increasing order
// of width... | nlogn | 476.java | 0.7 |
// Java program to calculate max_difference between
// the sum of two subarrays of length k and N - k
import
java.util.*;
class
GFG
{
// Function to calculate max_difference
static
int
maxDifference(
int
arr[],
int
N,
int
k)
{
int
M, S =
0
, S1 =
0
, max_difference =
0
;
// Sum of the array
for
(
... | nlogn | 477.java | 0.7 |
// Sorting based Java program to find
// all elements in array which have
// atleast two greater elements itself.
import
java.util.*;
import
java.io.*;
class
GFG
{
static
void
findElements(
int
arr[],
int
n)
{
Arrays.sort(arr);
for
(
int
i =
0
; i < n -
2
; i++)
System.out.print(arr[i] +
" "
);
}... | nlogn | 48.java | 0.7 |
// Java program to find minimum sum of
// absolute differences of two arrays.
import
java.util.Arrays;
class
MinSum
{
// Returns minimum possible pairwise
// absolute difference of two arrays.
static
long
findMinSum(
long
a[],
long
b[],
long
n)
{
// Sort both arrays
Arrays.sort(a);
Arrays.sort(b);... | nlogn | 480.java | 0.7 |
// Java program to find minimum sum of two numbers
// formed from all digits in a given array.
import
java.util.PriorityQueue;
class
MinSum
{
// Returns sum of two numbers formed
// from all digits in a[]
public
static
long
solve(
int
[] a)
{
// min Heap
PriorityQueue<Integer> pq =
new
PriorityQueue<... | nlogn | 482.java | 0.7 |
// Java code to count the change required to
// convert the array into non-increasing array
import
java.util.PriorityQueue;
class
GFG
{
public
static
int
DecreasingArray(
int
a[],
int
n)
{
int
sum =
0
, dif =
0
;
PriorityQueue<Integer> pq =
new
PriorityQueue<>();
// Here in the loop we will
// c... | nlogn | 483.java | 0.7 |
// Java program to find minimum
// increment/decrement operations
// to make array elements same.
import
java.util.Arrays;
import
java.io.*;
class
GFG
{
static
int
MinOperation(
int
a[],
int
b[],
int
n)
{
// sorting both arrays
// in ascending order
Arrays.sort(a);
Arrays.sort(b);
// variable ... | nlogn | 484.java | 0.7 |
// Java program to find possibility to sort
// by multiple subarray reverse operation
import
java.util.*;
class
GFG {
static
boolean
ifPossible(
int
arr[],
int
n)
{
// making the copy of the original array
int
copy[] = Arrays.copyOf(arr, arr.length);
// sorting the copied array
Arrays.sort(copy);
... | nlogn | 485.java | 0.7 |
// Java code to find sum of
// all area rectangle possible
import
java.io.*;
import
java.util.Arrays;
class
GFG
{
// Function to find
// area of rectangles
static
int
MaxTotalRectangleArea(
int
[]a,
int
n)
{
// sorting the array in
// descending order
Arrays.sort(a);
// store the final sum of... | nlogn | 486.java | 0.7 |
// Java program to solve fractional Knapsack Problem
import
java.util.Arrays;
import
java.util.Comparator;
// Greedy approach
public
class
FractionalKnapSack
{
// Time complexity O(n log n)
public
static
void
main(String[] args)
{
int
[] wt = {
10
,
40
,
20
,
30
};
int
[] val = {
60
,
40
,
100
,
... | nlogn | 491.java | 0.7 |
// Java implementation to find the
// minimum and maximum amount
import
java.util.*;
class
GFG {
// Function to find the minimum
// amount to buy all candies
static
int
findMinimum(
int
arr[],
int
n,
int
k)
{
int
res =
0
;
for
(
int
i =
0
; i < n; i++)
{
// Buy current candy
res += arr[i];
... | nlogn | 493.java | 0.7 |
// Java program to find minimum
// difference between groups of
// highest and lowest sums.
import
java.util.Arrays;
import
java.util.Collections;
import
java.util.Vector;
class
GFG {
static
long
calculate(
long
a[],
int
n)
{
// Sorting the whole array.
Arrays.sort(a);
int
i,j;
// Generating sum g... | nlogn | 498.java | 0.7 |
// Java program to connect n ropes with minimum cost
// A class for Min Heap
class
MinHeap {
int
[] harr;
// Array of elements in heap
int
heap_size;
// Current number of elements in min heap
int
capacity;
// maximum possible size of min heap
// Constructor: Builds a heap from
// a given array a[] of ... | nlogn | 499.java | 0.7 |
// Java program to acquire
// all n coins
import
java.util.Arrays;
class
GFG
{
// function to calculate min cost
static
int
minCost(
int
coin[],
int
n,
int
k)
{
// sort the coins value
Arrays.sort(coin);
// calculate no. of
// coins needed
int
coins_needed = (
int
)Math.ceil(
1.0
*
n / (k ... | nlogn | 501.java | 0.7 |
// C# program to acquire all n coins at
// minimum cost with multiple values of k.
import
java .io.*;
import
java.util.Arrays;
public
class
GFG {
// Converts coin[] to prefix sum array
static
void
preprocess(
int
[]coin,
int
n)
{
// sort the coins value
Arrays.sort(coin);
// Maintain prefix sum ar... | nlogn | 502.java | 0.7 |
// Program to find minimum number of platforms
import
java.util.*;
class
GFG {
// Returns minimum number of platforms reqquired
static
int
findPlatform(
int
arr[],
int
dep[],
int
n)
{
// Sort arrival and departure arrays
Arrays.sort(arr);
Arrays.sort(dep);
// plat_needed indicates number of platform... | nlogn | 503.java | 0.7 |
// Java program to find the minimum possible
// difference between maximum and minimum
// elements when we have to add/subtract
// every number by k
import
java.util.*;
class
GFG {
// Modifies the array by subtracting/adding
// k to every element such that the difference
// between maximum and minimum is ... | nlogn | 504.java | 0.7 |
// Program to make all array equal
import
java.io.*;
import
java.util.Arrays;
class
GFG {
// function for calculating min operations
static
int
minOps(
int
arr[],
int
n,
int
k)
{
// max elements of array
Arrays.sort(arr);
int
max = arr[arr.length -
1
];
int
res =
0
;
// iterate for all element... | nlogn | 505.java | 0.7 |
// Java code to find minimum number of elements
// such that their sum is greater than sum of
// remaining elements of the array.
import
java.io.*;
import
java.util.*;
class
GFG {
// Function to find minimum elements needed
static
int
minElements(
int
arr[],
int
n)
{
// Calculating HALF of array sum
... | nlogn | 510.java | 0.7 |
import
java.util.*;
import
java.lang.*;
class
Main
{
static
void
minAbsSumPair(
int
arr[],
int
n)
{
// Variables to keep track of current sum and minimum sum
int
sum, min_sum =
999999
;
// left and right index variables
int
l =
0
, r = n-
1
;
// variable to keep track of the left and right pair f... | nlogn | 523.java | 0.7 |
// Java code for k largest elements in an array
import
java.util.Arrays;
import
java.util.Collections;
class
GFG {
public
static
void
kLargest(Integer[] arr,
int
k)
{
// Sort the given array arr in reverse order
// This method doesn't work with primitive data
// types. So, instead of int, Integer type
... | nlogn | 525.java | 0.7 |
// Java code for kth smallest element
// in an array
import
java.util.Arrays;
import
java.util.Collections;
class
GFG
{
// Function to return k'th smallest
// element in a given array
public
static
int
kthSmallest(Integer [] arr,
int
k)
{
// Sort the given array
Arrays.sort(arr);
// Return k'th ... | nlogn | 546.java | 0.7 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Arrays;
public class Main {
static StreamTokenizer st=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
public static void main(String[] args) {
in... | nlogn | 561.java | 0.7 |
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(new PrintStream(System.out));
StringTokenizer st = new StringToken... | nlogn | 562.java | 0.7 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.PriorityQueue;
import ja... | nlogn | 564.java | 0.7 |
import java.util.Scanner;
public class Fly {
static double ERROR = 0.0000001;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int m = scanner.nextInt();
int [] a = new int[n + 1];
int [] b = new int[n + 1... | nlogn | 572.java | 0.7 |
import java.util.Scanner;
import java.util.Vector;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int a[] = new int[n];
int b[] = new int[n];
for (int i = 0; i < n; i++) ... | nlogn | 575.java | 0.7 |
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
public class BigInteger7 {
public static void main(String[] args) {
//https://codeforces.com/contest/1011/problem/A
Scanner scanner = new Scanner(System.in);
BigInteger n = scanner.nextBigInteger();
BigI... | nlogn | 577.java | 0.7 |
import java.util.*;
public class HelloWorld {
static long SQR(long a) {
return a * a;
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
String str = sc.next();
char s[] = str.toCharArray();
Arrays.parallelSort(s);
str = new S... | nlogn | 579.java | 0.7 |
// Java program to find the sum
// in a given range in an array
// using sparse table.
class
GFG
{
// Because 2^17 is larger than 10^5
static
int
k =
16
;
// Maximum value of array
static
int
N =
100000
;
// k + 1 because we need
// to access table[r][k]
static
long
table[][] =
new
long
[N][k +
1
]; ... | nlogn | 58.java | 0.7 |
import java.util.Arrays;
import java.util.Scanner;
public class Solution {
private static int[] a;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), m = sc.nextInt();
a = new int[101];
for (int i = 0; i < m; i++) {
... | nlogn | 584.java | 0.7 |
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Solution solution = new Solution();
System.out.println(solution.solve());
}
private int solve() {
Scanner in = new Scan... | nlogn | 586.java | 0.7 |
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
long totalBlocks = 0;
long a[] = new long[n];
for(int i = 0; i < n; ++i) {
a[i] = sc.nextLo... | nlogn | 605.java | 0.7 |
import java.util.*;
import java.io.*;
public class A
{
public static void main(String ar[]) throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String s1[]=br.readLine().split(" ");
int n=Integer.parseInt(s1[0]);
int m=In... | nlogn | 606.java | 0.7 |
import java.util.*;
public class test{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
int n=s.nextInt();
int m=s.nextInt();
int arr[]=new int[n];
int max = Integer.MIN_VALUE;
long sum = 0;
for(int i=0;i<n;i++)
{
arr[i] = s.nextInt();
sum = sum ... | nlogn | 607.java | 0.7 |
import java.util.*;
import java.io.*;
import java.awt.Point;
import java.math.BigInteger;
public class stacks {
public static void main(String[] args) throws Exception {
FastIO sc = new FastIO(System.in);
PrintWriter pw = new PrintWriter(System.out);
int n = sc.nextInt();
int m = sc.nextInt();
long r... | nlogn | 610.java | 0.7 |
import java.util.*;
import java.io.*;
public class A
{
public static void main(String ar[]) throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String s1[]=br.readLine().split(" ");
int n=Integer.parseInt(s1[0]);
long x=L... | nlogn | 612.java | 0.7 |
import java.awt.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.List;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt(), m = scanner.nextInt();
int[] vertical ... | nlogn | 626.java | 0.7 |
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;
import java.io.Inp... | nlogn | 627.java | 0.7 |
import java.io.*;
import java.util.*;
public class A4 {
public BufferedReader input;
public PrintWriter output;
public StringTokenizer stoken = new StringTokenizer("");
public static void main(String[] args) throws IOException {
new A4();
}
A4() throws IOException {
input = n... | nlogn | 629.java | 0.7 |
import java.util.*;
import java.io.*;
import java.math.*;
public class loser
{
static class InputReader {
public BufferedReader br;
public StringTokenizer token;
public InputReader(InputStream stream)
{
br=new BufferedReader(new InputStreamReader(stream),32768);
... | nlogn | 649.java | 0.7 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class CoveredPointsCount {
//UPSOLVE
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStre... | nlogn | 651.java | 0.7 |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual soluti... | nlogn | 652.java | 0.7 |
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
int[] arr = new int[n];
HashMap<Integer, Integer> m... | nlogn | 661.java | 0.7 |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
public class Main {
static BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
st... | nlogn | 663.java | 0.7 |
//package fourninetysixDiv3;
import java.util.HashMap;
import java.util.Scanner;
public class Median_Segments_general {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int m = s.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = s.n... | nlogn | 664.java | 0.7 |
import java.io.*;
import java.util.*;
public class Solution {
static class Data{
int x,i;
Data(int x,int i){
this.x = x;
this.i = i;
}
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStream... | nlogn | 666.java | 0.7 |
import java.util.Scanner;
public class Fly {
static double ERROR = 0.0000001;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int m = scanner.nextInt();
int [] a = new int[n + 1];
int [] b = new int[n + 1... | nlogn | 677.java | 0.7 |
import java.util.Scanner;
import java.util.Vector;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int a[] = new int[n];
int b[] = new int[n];
for (int i = 0; i < n; i++) ... | nlogn | 680.java | 0.7 |
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
public class BigInteger7 {
public static void main(String[] args) {
//https://codeforces.com/contest/1011/problem/A
Scanner scanner = new Scanner(System.in);
BigInteger n = scanner.nextBigInteger();
BigI... | nlogn | 682.java | 0.7 |
import java.util.*;
public class HelloWorld {
static long SQR(long a) {
return a * a;
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
String str = sc.next();
char s[] = str.toCharArray();
Arrays.parallelSort(s);
str = new S... | nlogn | 684.java | 0.7 |
import java.util.Arrays;
import java.util.Scanner;
public class Solution {
private static int[] a;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), m = sc.nextInt();
a = new int[101];
for (int i = 0; i < m; i++) {
... | nlogn | 689.java | 0.7 |
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Solution solution = new Solution();
System.out.println(solution.solve());
}
private int solve() {
Scanner in = new Scan... | nlogn | 691.java | 0.7 |
// Java program to find the minimum possible
// difference between maximum and minimum
// elements when we have to add/subtract
// every number by k
import
java.util.*;
class
GFG {
// Modifies the array by subtracting/adding
// k to every element such that the difference
// between maximum and minimum is ... | nlogn | 70.java | 0.7 |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.Fi... | nlogn | 707.java | 0.7 |
import java.io.*;
import java.util.Arrays;
import java.util.Random;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.concurrent.ThreadLocalRandom;
import java.util.function.Function;
public class Main {
static int T;
public static void main(String[] args) {
FastScanne... | nlogn | 727.java | 0.7 |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.HashMap;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**... | nlogn | 737.java | 0.7 |
import com.sun.org.apache.xpath.internal.operations.Bool;
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
MyScanner scan = new MyScanner();
out = new PrintWriter(new BufferedOutputStream(System.out));
int n = scan.nextIn... | nlogn | 744.java | 0.7 |
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;
public class Main implements Runnable {
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numCha... | nlogn | 749.java | 0.7 |
import java.io.*;
import java.util.*;
import java.util.function.Function;
public class Main {
static int N;
static int[] U, V;
static int[] A;
public static void main(String[] args) {
FastScanner sc = new FastScanner(System.in);
N = sc.nextInt();
U = new int[N-1];
V = ... | nlogn | 751.java | 0.7 |
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;
public class gambling {
public static void main(String[] args) throws IOException{
Reader rd = new Reader();
PrintWriter out... | nlogn | 755.java | 0.7 |
import java.io.*;
import java.util.*;
public class p7{
static class FastReader{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements())
{
try
... | nlogn | 760.java | 0.7 |
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
long totalBlocks = 0;
long a[] = new long[n];
for(int i = 0; i < n; ++i) {
a[i] = sc.nextLo... | nlogn | 767.java | 0.7 |
/*
Keep solving problems.
*/
import java.util.*;
import java.io.*;
public class CFA {
BufferedReader br;
PrintWriter out;
StringTokenizer st;
boolean eof;
private static long MOD = 1000L * 1000L * 1000L + 7;
private static final int[] dx = {0, -1, 0, 1};
private static final int[] dy = {1,... | nlogn | 784.java | 0.7 |
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;
public class Div... | nlogn | 787.java | 0.7 |
import java.util.*;
import java.io.*;
public class Three{
public static void main(String[] args) {
Scanner in = new Scanner (System.in);
PrintWriter out = new PrintWriter(System.out);
pair[] points = new pair [3];
for (int i = 0; i < 3; ++i) {
int x = in.nextInt();
int y = in.nextInt();
points[... | nlogn | 788.java | 0.7 |
import java.io.*;
import java.util.*;
public class cf {
static class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner(Reader in) {
br = new BufferedReader(in);
}
public FastScanner() {
this(new InputStreamReade... | nlogn | 792.java | 0.7 |
import java.math.BigInteger;
import java.util.Scanner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Andy Phan
*/
public class p1096f {
static long MOD = 9... | nlogn | 805.java | 0.7 |
import java.io.*;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) {
FastScanner sc = new FastScanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int N = sc.nextInt();
long dest = sc.nextLong();
long max = (long)... | nlogn | 808.java | 0.7 |
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class A {
static MyScanner sc;
static PrintWriter pw;
public static void main(String[] args) throws Throwable {
sc = new MyScanner();
pw = new PrintWriter(System.out);
n = sc.nextInt();
T = sc.nextLo... | nlogn | 810.java | 0.7 |
import java.io.*;
import java.util.*;
public class Main{
public static void main(String[] args){
try {
new Main().solve();
} catch (Exception e) {
e.printStackTrace();
}
}
ArrayList<Edge>[]edge;
int n,m,cnt=0;
int ord;
int[]order;int[]vis;
Edg... | nlogn | 812.java | 0.7 |
import java.util.*;
public class bOX {
public static void main(String ars[]){
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int max = 0;
Map<Integer,Integer> map = new HashMap<>();
for(int i=0;i<n;i++){
int x = s.nextInt();
if(!map.cont... | nlogn | 818.java | 0.7 |
/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
public static void main (String[] args) throws java.lang.Exception
{
BufferedReader br=new Bu... | nlogn | 819.java | 0.7 |
// Java program to find minimum difference between
// any pair in an unsorted array
import
java.util.Arrays;
class
GFG
{
// Returns minimum difference between any pair
static
int
findMinDiff(
int
[] arr,
int
n)
{
// Sort array in non-decreasing order
Arrays.sort(arr);
// Initialize difference as in... | nlogn | 83.java | 0.7 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.StringTokenizer;
public class c {
public st... | nlogn | 833.java | 0.7 |
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main {
static int n;
static long TotalTime;
static Problem[] problems;
static StringBuilder sb;
public static void main(String[] args) {
FastScanner sc = new FastScanner();
sb = new StringBuilder();... | nlogn | 838.java | 0.7 |
// discussed with rainboy
import java.io.*;
import java.util.*;
public class CF915E {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
int n = Integer.parseInt(br.readLine());
int... | nlogn | 844.java | 0.7 |
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Problem
{
static int mod = (int) (1e9+7);
static InputReader in;
static PrintWriter out;
static int[] rt;
static int[] size;
static void initialize(int n){
rt = new int[n + 1];
size = new int[n + 1... | nlogn | 845.java | 0.7 |
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
public class RadioStation {
public static BufferedReader in = new BufferedRead... | nlogn | 847.java | 0.7 |
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
public class codeforces
{
public static void main(String[] args)
{
InputReader in = new InputReader(System.in);
PrintWriter pw = new PrintWriter(System.out);
int n = in.nextInt();
long U = in.nextLong();
long[] E = ne... | nlogn | 850.java | 0.7 |
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
public static void main(String[] args) throws IOException {
PrintWriter out = new PrintWriter(System.out);
//Scanner sc = new Scanner();
Reader in = new Reader();
Main solver = new Main();
solver.... | nlogn | 855.java | 0.7 |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.ListIterator;
import java.util.Collection;
import java.util.AbstractList;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Deq... | nlogn | 866.java | 0.7 |
// Java program to print an array in alternate
// sorted manner
import
java.io.*;
import
java.util.Arrays;
class
AlternativeString
{
// Function to print alternate sorted values
static
void
alternateSort(
int
arr[],
int
n)
{
Arrays.sort(arr);
// Printing the last element of array
// first and then ... | nlogn | 87.java | 0.7 |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper... | nlogn | 872.java | 0.7 |
//Author: Patel Rag
//Java version "1.8.0_211"
import java.util.*;
import java.io.*;
public class Main
{
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); }
String next()
{
while (st == null |... | nlogn | 879.java | 0.7 |
// Java program to sort an array according absolute
// difference with x.
import
java.io.*;
import
java.util.*;
class
GFG
{
// Function to sort an array according absolute
// difference with x.
static
void
rearrange(
int
[] arr,
int
n,
int
x)
{
TreeMap<Integer, ArrayList<Integer>> m =
new
TreeMap<>... | nlogn | 88.java | 0.7 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import static java.lang.Math.*;
public class Main2 {
private FastScanner scanner = new FastScanner();
public static void main(String[] args) {
new Main2().solve();
}
private void... | nlogn | 882.java | 0.7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.