exec_outcome stringclasses 1
value | code_uid stringlengths 32 32 | file_name stringclasses 111
values | prob_desc_created_at stringlengths 10 10 | prob_desc_description stringlengths 63 3.8k | prob_desc_memory_limit stringclasses 18
values | source_code stringlengths 117 65.5k | lang_cluster stringclasses 1
value | prob_desc_sample_inputs stringlengths 2 802 | prob_desc_time_limit stringclasses 27
values | prob_desc_sample_outputs stringlengths 2 796 | prob_desc_notes stringlengths 4 3k ⌀ | lang stringclasses 5
values | prob_desc_input_from stringclasses 3
values | tags listlengths 0 11 | src_uid stringlengths 32 32 | prob_desc_input_spec stringlengths 28 2.37k ⌀ | difficulty int64 -1 3.5k ⌀ | prob_desc_output_spec stringlengths 17 1.47k ⌀ | prob_desc_output_to stringclasses 3
values | hidden_unit_tests stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
PASSED | 3e6437c4168bf75d2de87174d16090b5 | train_002.jsonl | 1443430800 | Three companies decided to order a billboard with pictures of their logos. A billboard is a big square board. A logo of each company is a rectangle of a non-zero area. Advertisers will put up the ad only if it is possible to place all three logos on the billboard so that they do not overlap and the billboard has no emp... | 256 megabytes | import java.util.*;
import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
public class CodeForces
{
FastScanner in;
PrintWriter out;
class pair implements Comparable
{
int min, max;
char symb;
pair (int a, int b, char ch)
{
min = Math.min(a, b);
... | Java | ["5 1 2 5 5 2", "4 4 2 6 4 2"] | 1 second | ["5\nAAAAA\nBBBBB\nBBBBB\nCCCCC\nCCCCC", "6\nBBBBBB\nBBBBBB\nAAAACC\nAAAACC\nAAAACC\nAAAACC"] | null | Java 7 | standard input | [
"geometry",
"constructive algorithms",
"bitmasks",
"math",
"implementation",
"brute force"
] | 2befe5da2df57d23934601cbe4d4f151 | The first line of the input contains six positive integers x1, y1, x2, y2, x3, y3 (1 ≤ x1, y1, x2, y2, x3, y3 ≤ 100), where xi and yi determine the length and width of the logo of the i-th company respectively. | 1,700 | If it is impossible to place all the three logos on a square shield, print a single integer "-1" (without the quotes). If it is possible, print in the first line the length of a side of square n, where you can place all the three logos. Each of the next n lines should contain n uppercase English letters "A", "B" or "C"... | standard output | |
PASSED | cacd2054b5db0b0be3e23e9066c75455 | train_002.jsonl | 1443430800 | Three companies decided to order a billboard with pictures of their logos. A billboard is a big square board. A logo of each company is a rectangle of a non-zero area. Advertisers will put up the ad only if it is possible to place all three logos on the billboard so that they do not overlap and the billboard has no emp... | 256 megabytes | import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
public class P581D {
private void run() {
int x1 = nextInt();
int y1 = nextInt... | Java | ["5 1 2 5 5 2", "4 4 2 6 4 2"] | 1 second | ["5\nAAAAA\nBBBBB\nBBBBB\nCCCCC\nCCCCC", "6\nBBBBBB\nBBBBBB\nAAAACC\nAAAACC\nAAAACC\nAAAACC"] | null | Java 7 | standard input | [
"geometry",
"constructive algorithms",
"bitmasks",
"math",
"implementation",
"brute force"
] | 2befe5da2df57d23934601cbe4d4f151 | The first line of the input contains six positive integers x1, y1, x2, y2, x3, y3 (1 ≤ x1, y1, x2, y2, x3, y3 ≤ 100), where xi and yi determine the length and width of the logo of the i-th company respectively. | 1,700 | If it is impossible to place all the three logos on a square shield, print a single integer "-1" (without the quotes). If it is possible, print in the first line the length of a side of square n, where you can place all the three logos. Each of the next n lines should contain n uppercase English letters "A", "B" or "C"... | standard output | |
PASSED | 0a0f9169f8939beac01a70e8b71e2951 | train_002.jsonl | 1443430800 | Three companies decided to order a billboard with pictures of their logos. A billboard is a big square board. A logo of each company is a rectangle of a non-zero area. Advertisers will put up the ad only if it is possible to place all three logos on the billboard so that they do not overlap and the billboard has no emp... | 256 megabytes | import java.io.*;
import java.util.*;
public class C322D
{
public static StringTokenizer st;
public static void nextLine(BufferedReader br) throws IOException
{
st = new StringTokenizer(br.readLine());
}
public static String next()
{
return st.nextToken();
}
pu... | Java | ["5 1 2 5 5 2", "4 4 2 6 4 2"] | 1 second | ["5\nAAAAA\nBBBBB\nBBBBB\nCCCCC\nCCCCC", "6\nBBBBBB\nBBBBBB\nAAAACC\nAAAACC\nAAAACC\nAAAACC"] | null | Java 7 | standard input | [
"geometry",
"constructive algorithms",
"bitmasks",
"math",
"implementation",
"brute force"
] | 2befe5da2df57d23934601cbe4d4f151 | The first line of the input contains six positive integers x1, y1, x2, y2, x3, y3 (1 ≤ x1, y1, x2, y2, x3, y3 ≤ 100), where xi and yi determine the length and width of the logo of the i-th company respectively. | 1,700 | If it is impossible to place all the three logos on a square shield, print a single integer "-1" (without the quotes). If it is possible, print in the first line the length of a side of square n, where you can place all the three logos. Each of the next n lines should contain n uppercase English letters "A", "B" or "C"... | standard output | |
PASSED | d82a0856ff3a6ac6d862846de34a7b58 | train_002.jsonl | 1443430800 | Three companies decided to order a billboard with pictures of their logos. A billboard is a big square board. A logo of each company is a rectangle of a non-zero area. Advertisers will put up the ad only if it is possible to place all three logos on the billboard so that they do not overlap and the billboard has no emp... | 256 megabytes | import java.io.*;
import java.util.*;
public class Codeforces {
private static class Rect {
int x;
int y;
char color;
boolean inv;
private Rect(int x, int y, char color) {
this.color = color;
if (x < y) {
int temp = x;
... | Java | ["5 1 2 5 5 2", "4 4 2 6 4 2"] | 1 second | ["5\nAAAAA\nBBBBB\nBBBBB\nCCCCC\nCCCCC", "6\nBBBBBB\nBBBBBB\nAAAACC\nAAAACC\nAAAACC\nAAAACC"] | null | Java 7 | standard input | [
"geometry",
"constructive algorithms",
"bitmasks",
"math",
"implementation",
"brute force"
] | 2befe5da2df57d23934601cbe4d4f151 | The first line of the input contains six positive integers x1, y1, x2, y2, x3, y3 (1 ≤ x1, y1, x2, y2, x3, y3 ≤ 100), where xi and yi determine the length and width of the logo of the i-th company respectively. | 1,700 | If it is impossible to place all the three logos on a square shield, print a single integer "-1" (without the quotes). If it is possible, print in the first line the length of a side of square n, where you can place all the three logos. Each of the next n lines should contain n uppercase English letters "A", "B" or "C"... | standard output | |
PASSED | ad059ff57067713419e67b936a863ddb | train_002.jsonl | 1443430800 | Three companies decided to order a billboard with pictures of their logos. A billboard is a big square board. A logo of each company is a rectangle of a non-zero area. Advertisers will put up the ad only if it is possible to place all three logos on the billboard so that they do not overlap and the billboard has no emp... | 256 megabytes | //package threelogos;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
public class ThreeLogos {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStr... | Java | ["5 1 2 5 5 2", "4 4 2 6 4 2"] | 1 second | ["5\nAAAAA\nBBBBB\nBBBBB\nCCCCC\nCCCCC", "6\nBBBBBB\nBBBBBB\nAAAACC\nAAAACC\nAAAACC\nAAAACC"] | null | Java 7 | standard input | [
"geometry",
"constructive algorithms",
"bitmasks",
"math",
"implementation",
"brute force"
] | 2befe5da2df57d23934601cbe4d4f151 | The first line of the input contains six positive integers x1, y1, x2, y2, x3, y3 (1 ≤ x1, y1, x2, y2, x3, y3 ≤ 100), where xi and yi determine the length and width of the logo of the i-th company respectively. | 1,700 | If it is impossible to place all the three logos on a square shield, print a single integer "-1" (without the quotes). If it is possible, print in the first line the length of a side of square n, where you can place all the three logos. Each of the next n lines should contain n uppercase English letters "A", "B" or "C"... | standard output | |
PASSED | b21042e8a95120ddbf36b7c9030633fa | train_002.jsonl | 1443430800 | Three companies decided to order a billboard with pictures of their logos. A billboard is a big square board. A logo of each company is a rectangle of a non-zero area. Advertisers will put up the ad only if it is possible to place all three logos on the billboard so that they do not overlap and the billboard has no emp... | 256 megabytes | import java.util.*;
public class Main {
static class Pair implements Comparable<Pair>
{
int x,y,z;
Pair(int a,int b,int c)
{
x=a;y=b;z=c;
}
public int compareTo(Pair p) {
return this.y-p.y;
}
}
static int a,b,c,n;
static Pair[] aa=new Pair[3];
static int[][] map=new int[200][200];
public stati... | Java | ["5 1 2 5 5 2", "4 4 2 6 4 2"] | 1 second | ["5\nAAAAA\nBBBBB\nBBBBB\nCCCCC\nCCCCC", "6\nBBBBBB\nBBBBBB\nAAAACC\nAAAACC\nAAAACC\nAAAACC"] | null | Java 7 | standard input | [
"geometry",
"constructive algorithms",
"bitmasks",
"math",
"implementation",
"brute force"
] | 2befe5da2df57d23934601cbe4d4f151 | The first line of the input contains six positive integers x1, y1, x2, y2, x3, y3 (1 ≤ x1, y1, x2, y2, x3, y3 ≤ 100), where xi and yi determine the length and width of the logo of the i-th company respectively. | 1,700 | If it is impossible to place all the three logos on a square shield, print a single integer "-1" (without the quotes). If it is possible, print in the first line the length of a side of square n, where you can place all the three logos. Each of the next n lines should contain n uppercase English letters "A", "B" or "C"... | standard output | |
PASSED | 9e04d82b16686dadcaac216576c08775 | train_002.jsonl | 1443430800 | Three companies decided to order a billboard with pictures of their logos. A billboard is a big square board. A logo of each company is a rectangle of a non-zero area. Advertisers will put up the ad only if it is possible to place all three logos on the billboard so that they do not overlap and the billboard has no emp... | 256 megabytes | import java.util.*;
public class three_logos
{
public static void main( String[] args )
{
Scanner in = new Scanner( System.in );
int a1 = in.nextInt(), a2 = in.nextInt();
int b1 = in.nextInt(), b2 = in.nextInt();
int c1 = in.nextInt(), c2 = in.nextInt();
int d = a1 * a2 ... | Java | ["5 1 2 5 5 2", "4 4 2 6 4 2"] | 1 second | ["5\nAAAAA\nBBBBB\nBBBBB\nCCCCC\nCCCCC", "6\nBBBBBB\nBBBBBB\nAAAACC\nAAAACC\nAAAACC\nAAAACC"] | null | Java 7 | standard input | [
"geometry",
"constructive algorithms",
"bitmasks",
"math",
"implementation",
"brute force"
] | 2befe5da2df57d23934601cbe4d4f151 | The first line of the input contains six positive integers x1, y1, x2, y2, x3, y3 (1 ≤ x1, y1, x2, y2, x3, y3 ≤ 100), where xi and yi determine the length and width of the logo of the i-th company respectively. | 1,700 | If it is impossible to place all the three logos on a square shield, print a single integer "-1" (without the quotes). If it is possible, print in the first line the length of a side of square n, where you can place all the three logos. Each of the next n lines should contain n uppercase English letters "A", "B" or "C"... | standard output | |
PASSED | 908ac5f2614b4f944f938e004b7a69a2 | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
static class Scan {
private byte[] buf=new byte[1024];
private int index;
private InputStream in;
private int total;
public Scan()
{
in=System.in;
}
public int scan()throws IOExcepti... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | a00833f99879d692b8e79de0101fa672 | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes |
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main {
static long sx = 0, sy = 0, m = (long) (1e9 + 7);
static ArrayList<pair>[] a;
static int[][] dp;
static long[] farr;
static boolean b = true;
// static HashMap<Long, Integer> hm = new HashMap<>();
static TreeMap<Integer, ... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | e7a6d66fa291f368c5dbd6b98b6c815a | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.util.*;
public class codechef {
public static void main(String args[]) throws Exception {
FastReader in = new FastReader(System.in);
int testcases=in.nextInt(),i;
StringBuilder sb = new StringBuilder();
start:while(... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | a8d55dd7c421cf962686717d37970a98 | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.util.*;
public class codechef {
public static void main(String args[]) throws Exception {
FastReader in = new FastReader(System.in);
int testcases=in.nextInt(),i;
StringBuilder sb = new StringBuilder();
start:while(... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | bcbd1b1100b273c69bbd6ad2779eac28 | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes |
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;
public class f
{
public static void print(String str,int val){
System.out.println(str+" "+val);
}
public long gcd(long a, long b) {
if (b==0L) return a;
return gcd(b,a%b);
}... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | ba44140007c8c2bdfb4a8ae68afee323 | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Solution{
public static void main(String[] args) throws Exception{
FastScanner fs = new FastScanner();
PrintWriter out = new PrintWriter(System... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | a206d818b3ac034bdcdade6f3ee31880 | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | 6bcb27ed657cce768e8a53feb6a6156d | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Solve7 {
public static void main(String[] args) throws IOException {
Prin... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | 5181df169d60213d0733ace1f383a6f2 | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes |
import java.util.*;import java.io.*;import java.math.*;
public class Main
{
public static void process()throws IOException
{
long n=nl(),m=nl();
if(n==m){
pn(n*(n+1l)/2l);
return;
}
long z=n-m;//no. of zeroes
long g=m+1l;//size ... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | e353988a568f65f995660f660c044d79 | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.io.*;
import java.math.*;
import java.util.*;
public class Sample
{
static int[][][] dp;
static int[] are;
public static void main(String[] args) throws InterruptedException {
Thread t=new Thread(null, null,"", 1<<28) {
public void run() {
m();
}
};
t.start();
t.join();
}
public s... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | 042d8de64ecd095094c9c9cd1b655726 | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | /**
* @author derrick20
*/
import java.io.*;
import java.util.*;
public class AyoubFunction {
public static void main(String[] args) throws Exception {
FastScanner sc = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int T = sc.nextInt();
while (T-->0) {
... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | 07736ac4722821f5931f6d5d2cd30ac4 | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
import java.awt.Point;
// U KNOW THAT IF THIS DAY WILL BE URS THEN NO ONE CAN DEFEAT U HERE................
// ASCII = 48 + i ;// 2^28 = 268,435,456 > 2* 10^8 // log 10 base 2 = 3.3219
// odd:: (x^2+1)/2 , (x^2-1)/2 ; x>=3// even:: (x^2/4)+1 ,(x^2/4)-1 x >=4... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | 117ffd09661d5a1f0d0e4ee4c78c0a61 | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.io.*;
import java.util.*;
public class CF1301C extends PrintWriter {
CF1301C() { super(System.out); }
Scanner sc = new Scanner(System.in);
public static void main(String[] $) {
CF1301C o = new CF1301C(); o.main(); o.flush();
}
void main() {
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | 16981aaaac88eb0dc423c2219e9eb652 | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.io.*;
import java.util.*;
import java.util.Map.Entry;
public class gym{
static long getSum(long i) {
return (i*(i+1))/2;
}
public static void main(String[] args) throws Exception{
MScanner sc=new MScanner(System.in);
PrintWriter pw=new PrintWriter(System.out);
int tc=sc.nextInt();
while(tc--... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | d773066eafe9fdb44b573e2e2b648e9f | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
public class Solution {
/* static int n;
static long max;
public static void recurse(int pos,String s,int rem){
if(pos==n){
calc(s);
retu... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | 77396af39fc56b99481e0fdcb941203e | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.util.Scanner;
public class ayoubsFunction {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
StringBuilder finAns = new StringBuilder();
while (--T >= 0) {
long n = sc.nextLong(), m = sc.nextLong();
long z = n - m;
long g = m + 1;
long... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | 7871bcd43b363d696d568b5c2893b58b | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.io.*;
import java.util.*;
public class C {
static long sum(long x) {
return x * (x + 1) / 2;
}
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner();
PrintWriter out = new PrintWriter(System.out);
int tc = sc.nextInt();
while (tc-- > 0) {
int n = sc.nex... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | 8feefe5f9e8e2c679441ce369bc4027d | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
public class cf1301c {
public static void main(String[] args) throws IOException {
int t = ri();
while(t --> 0) {
long n = rnl(), m = nl(), r = n - m;
if(m == 0) {
... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | 07af58e8ab1e242c236d55cdd7d2f966 | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
static int p=1000000007;
public static void main (String args[])throws IOException{
Scanner sc = new Scanner();
PrintWriter out = new PrintWriter(System.out);
int t=sc.nextInt();
while(t-->0) {
int n = sc.nextInt(), m=sc.n... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | 88d2f0b45ac8b8da0a0ef4e566e7d028 | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.io.*;
import java.util.*;
import java.lang.*;
public class Rextester{
public static void main(String[] args)throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer();
int t = Integer.parseInt(br.readLine())... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | 347535625add76b55ef8fc45870a3bd9 | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.util.*;
import java.io.*;
public class Function {
public static void main(String[] args) {
MyScanner s = new MyScanner();
int cases = s.nextInt();
for (int i = 0; i < cases; i++) {
long n = s.nextLong();
long m = s.nextLong();
long total = n *... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | 7c3ac2f8100c7703d80117e1965f5392 | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main implements Runnable{
private void solve()throws IOException{
int n=nextInt();
int m=nextInt();
int x=(n-m)/(m+1);
int y=(n-m)%(m+1);
long ans=1l*n*(n+1)/2;
ans-=1l*y*(x+1)*(x+2)/2;
ans-=1l*(m-y+1)*x*... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | d70e816913e625e0b914ff4c239ab42b | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.io.*;
import java.util.*;
public class C
{
void solve(FastIO io)
{
long n = io.nextInt();
long m = io.nextInt();
long zero = n - m;
long len = zero / (m+1);
long left = zero % (m+1);
long ans = left * ((((len + 2) * (len + 1)) / 2));
ans +=... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | 55044a8a187cf5cc8f4820ab0ea33e62 | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.util.*;
import java.io.*;
public class C619
{
public static void main(String [] args)
{
MyScanner sc = new MyScanner();
PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
int t = sc.nextInt();
while (t > 0) {
long n = sc.nextInt();
... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | 4f85920ef63ec693339c01b234a86584 | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes |
import java.util.*;
import java.io.*;
public class AyoubFunction_div2_619 {
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
PrintWriter out=new PrintWriter(System.out);
StringTokenizer st=new StringTokenizer(br.readLine());... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | d2c991da2ae6005125faac9e9f5252eb | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class A {
final static FastReader scan = new FastReader();
public static void main(String[] args)
{
int t = scan.nextInt();
while (t-->0){
long... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | ee52db3822d8d24e46d4c7d7a8ef2247 | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author Jenish
*/
public class Ma... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | d93c7d86861402d7a4d0d69585230509 | train_002.jsonl | 1581604500 | Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally,... | 256 megabytes | import java.util.*;
import java.math.*;
import java.io.*;
import java.text.*;
public class practice {
// heloo world nudniobv udivbo
// buyfhsfnoisdfnoi
public static void merge(int arr[], int l, int m, int r) {
// Find sizes of two subarrays to be merged
int n1 = m - l + 1;
int n2 ... | Java | ["5\n3 1\n3 2\n3 3\n4 0\n5 2"] | 1 second | ["4\n5\n6\n0\n12"] | NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and t... | Java 11 | standard input | [
"greedy",
"combinatorics",
"math",
"binary search",
"strings"
] | 7458f44802c134de6fed7b4de84ea68c | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the... | 1,700 | For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1". | standard output | |
PASSED | 7872e1bb705ac23532af84fccffd154f | train_002.jsonl | 1380295800 | The new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the booking clerk sell a ticket to each person and give the change if he initially has no money and sells the... | 256 megabytes | import java.util.Scanner;
public class Kino1 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int coin1 = 0, coin2 = 0;
for (int i = 0; i < n; i++) {
int correct = scanner.nextInt();
if (correct ... | Java | ["4\n25 25 50 50", "2\n25 100", "4\n50 50 25 25"] | 2 seconds | ["YES", "NO", "NO"] | null | Java 8 | standard input | [
"implementation",
"greedy"
] | 63b20ab2993fddf2cc469c4c4e8027df | The first line contains integer n (1 ≤ n ≤ 105) — the number of people in the line. The next line contains n integers, each of them equals 25, 50 or 100 — the values of the bills the people have. The numbers are given in the order from the beginning of the line (at the box office) to the end of the line. | 1,100 | Print "YES" (without the quotes) if the booking clerk can sell a ticket to each person and give the change. Otherwise print "NO". | standard output | |
PASSED | ebb930a59b9da56a3d9f123a33d80301 | train_002.jsonl | 1380295800 | The new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the booking clerk sell a ticket to each person and give the change if he initially has no money and sells the... | 256 megabytes | import java.util.Scanner;
public class elzhan {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int b25 = 0, b50 = 0;
for (int i = 0; i < n; i++) {
int next = sc.nextInt();
if (next == 25) b25++;
... | Java | ["4\n25 25 50 50", "2\n25 100", "4\n50 50 25 25"] | 2 seconds | ["YES", "NO", "NO"] | null | Java 8 | standard input | [
"implementation",
"greedy"
] | 63b20ab2993fddf2cc469c4c4e8027df | The first line contains integer n (1 ≤ n ≤ 105) — the number of people in the line. The next line contains n integers, each of them equals 25, 50 or 100 — the values of the bills the people have. The numbers are given in the order from the beginning of the line (at the box office) to the end of the line. | 1,100 | Print "YES" (without the quotes) if the booking clerk can sell a ticket to each person and give the change. Otherwise print "NO". | standard output | |
PASSED | 59260f65a8d4dd214f67c860bfe3dbd8 | train_002.jsonl | 1380295800 | The new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the booking clerk sell a ticket to each person and give the change if he initially has no money and sells the... | 256 megabytes | import java.util.Scanner;
public class Kino {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int coin1 = 0, coin2 = 0;
for (int i = 0; i < n; i++) {
int correct = scanner.nextInt();
if (correct =... | Java | ["4\n25 25 50 50", "2\n25 100", "4\n50 50 25 25"] | 2 seconds | ["YES", "NO", "NO"] | null | Java 8 | standard input | [
"implementation",
"greedy"
] | 63b20ab2993fddf2cc469c4c4e8027df | The first line contains integer n (1 ≤ n ≤ 105) — the number of people in the line. The next line contains n integers, each of them equals 25, 50 or 100 — the values of the bills the people have. The numbers are given in the order from the beginning of the line (at the box office) to the end of the line. | 1,100 | Print "YES" (without the quotes) if the booking clerk can sell a ticket to each person and give the change. Otherwise print "NO". | standard output | |
PASSED | 1329967ebd58e07466c2cc2ca129a3e7 | train_002.jsonl | 1380295800 | The new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the booking clerk sell a ticket to each person and give the change if he initially has no money and sells the... | 256 megabytes | import java.util.*;
import java.io.PrintWriter;
public class A349 implements Runnable {
private Scanner in = new Scanner(System.in);
private PrintWriter out = new PrintWriter(System.out);
private int n;
private int a[];
private String ans = "NO";
public static void main(String[] args) {
new Thread(new A349())... | Java | ["4\n25 25 50 50", "2\n25 100", "4\n50 50 25 25"] | 2 seconds | ["YES", "NO", "NO"] | null | Java 8 | standard input | [
"implementation",
"greedy"
] | 63b20ab2993fddf2cc469c4c4e8027df | The first line contains integer n (1 ≤ n ≤ 105) — the number of people in the line. The next line contains n integers, each of them equals 25, 50 or 100 — the values of the bills the people have. The numbers are given in the order from the beginning of the line (at the box office) to the end of the line. | 1,100 | Print "YES" (without the quotes) if the booking clerk can sell a ticket to each person and give the change. Otherwise print "NO". | standard output | |
PASSED | ba37ff1ae72ed96dcb1068b751217d0d | train_002.jsonl | 1380295800 | The new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the booking clerk sell a ticket to each person and give the change if he initially has no money and sells the... | 256 megabytes | import java.util.Scanner;
/**
*
* @author Temirlan
*/
public class t31 {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
String gl=sc.nextLine();
String vt=sc.nextLine();
String[] vt1=vt.split(" ");
int o1=Integer.parseInt(gl);
int[] o2=... | Java | ["4\n25 25 50 50", "2\n25 100", "4\n50 50 25 25"] | 2 seconds | ["YES", "NO", "NO"] | null | Java 8 | standard input | [
"implementation",
"greedy"
] | 63b20ab2993fddf2cc469c4c4e8027df | The first line contains integer n (1 ≤ n ≤ 105) — the number of people in the line. The next line contains n integers, each of them equals 25, 50 or 100 — the values of the bills the people have. The numbers are given in the order from the beginning of the line (at the box office) to the end of the line. | 1,100 | Print "YES" (without the quotes) if the booking clerk can sell a ticket to each person and give the change. Otherwise print "NO". | standard output | |
PASSED | e3dbf01c31bc1a6838945574c5a8fc4a | train_002.jsonl | 1380295800 | The new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the booking clerk sell a ticket to each person and give the change if he initially has no money and sells the... | 256 megabytes | import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
/**
*
* @author Muhammad Bahaa
*/
public class ACinemaLine {
public static void main(String[] args) {
int n, temp;
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
Scanner in = new Scanner(System.in);... | Java | ["4\n25 25 50 50", "2\n25 100", "4\n50 50 25 25"] | 2 seconds | ["YES", "NO", "NO"] | null | Java 8 | standard input | [
"implementation",
"greedy"
] | 63b20ab2993fddf2cc469c4c4e8027df | The first line contains integer n (1 ≤ n ≤ 105) — the number of people in the line. The next line contains n integers, each of them equals 25, 50 or 100 — the values of the bills the people have. The numbers are given in the order from the beginning of the line (at the box office) to the end of the line. | 1,100 | Print "YES" (without the quotes) if the booking clerk can sell a ticket to each person and give the change. Otherwise print "NO". | standard output | |
PASSED | 22d97107aa44421395c14d4ab8c3473c | train_002.jsonl | 1380295800 | The new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the booking clerk sell a ticket to each person and give the change if he initially has no money and sells the... | 256 megabytes | import java.util.Scanner;
/**
*
* @author Dell
*/
public class NewMain24 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner s = new Scanner(System.in);
int x = s.nextInt();
int coun... | Java | ["4\n25 25 50 50", "2\n25 100", "4\n50 50 25 25"] | 2 seconds | ["YES", "NO", "NO"] | null | Java 8 | standard input | [
"implementation",
"greedy"
] | 63b20ab2993fddf2cc469c4c4e8027df | The first line contains integer n (1 ≤ n ≤ 105) — the number of people in the line. The next line contains n integers, each of them equals 25, 50 or 100 — the values of the bills the people have. The numbers are given in the order from the beginning of the line (at the box office) to the end of the line. | 1,100 | Print "YES" (without the quotes) if the booking clerk can sell a ticket to each person and give the change. Otherwise print "NO". | standard output | |
PASSED | 7f8bd4fda56c0b151363858305fa10ab | train_002.jsonl | 1380295800 | The new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the booking clerk sell a ticket to each person and give the change if he initially has no money and sells the... | 256 megabytes | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
long n = in.nextInt();
long i,current;
long b25=0,b50=0,b100=0;
boolean flag=true;
for(i=0;i<n;i++)
{
current = in.nextInt();
if(curren... | Java | ["4\n25 25 50 50", "2\n25 100", "4\n50 50 25 25"] | 2 seconds | ["YES", "NO", "NO"] | null | Java 8 | standard input | [
"implementation",
"greedy"
] | 63b20ab2993fddf2cc469c4c4e8027df | The first line contains integer n (1 ≤ n ≤ 105) — the number of people in the line. The next line contains n integers, each of them equals 25, 50 or 100 — the values of the bills the people have. The numbers are given in the order from the beginning of the line (at the box office) to the end of the line. | 1,100 | Print "YES" (without the quotes) if the booking clerk can sell a ticket to each person and give the change. Otherwise print "NO". | standard output | |
PASSED | f82bec53a3b9ddf92cccd03f921e2ab2 | train_002.jsonl | 1380295800 | The new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the booking clerk sell a ticket to each person and give the change if he initially has no money and sells the... | 256 megabytes | import java.util.*;
import java.util.Scanner;
public class JavaApplication3 {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int numberofpeople = in.nextInt();
int dvacatpyat = 0;
int pyadesyat = 0;
int count = 1;
for (int i=0;i<... | Java | ["4\n25 25 50 50", "2\n25 100", "4\n50 50 25 25"] | 2 seconds | ["YES", "NO", "NO"] | null | Java 8 | standard input | [
"implementation",
"greedy"
] | 63b20ab2993fddf2cc469c4c4e8027df | The first line contains integer n (1 ≤ n ≤ 105) — the number of people in the line. The next line contains n integers, each of them equals 25, 50 or 100 — the values of the bills the people have. The numbers are given in the order from the beginning of the line (at the box office) to the end of the line. | 1,100 | Print "YES" (without the quotes) if the booking clerk can sell a ticket to each person and give the change. Otherwise print "NO". | standard output | |
PASSED | e6a20e3578dd94976c2d45d134b152fa | train_002.jsonl | 1380295800 | The new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the booking clerk sell a ticket to each person and give the change if he initially has no money and sells the... | 256 megabytes |
import java.io.*;
import java.math.BigInteger;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
public class Main {
static final int INF = Integer.MAX_VALUE;
static void mergeSort(int[] a, int p, int r) {
if (p < r) {
in... | Java | ["4\n25 25 50 50", "2\n25 100", "4\n50 50 25 25"] | 2 seconds | ["YES", "NO", "NO"] | null | Java 8 | standard input | [
"implementation",
"greedy"
] | 63b20ab2993fddf2cc469c4c4e8027df | The first line contains integer n (1 ≤ n ≤ 105) — the number of people in the line. The next line contains n integers, each of them equals 25, 50 or 100 — the values of the bills the people have. The numbers are given in the order from the beginning of the line (at the box office) to the end of the line. | 1,100 | Print "YES" (without the quotes) if the booking clerk can sell a ticket to each person and give the change. Otherwise print "NO". | standard output | |
PASSED | f4b1e15b162e131cdd986d7737d0358d | train_002.jsonl | 1380295800 | The new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the booking clerk sell a ticket to each person and give the change if he initially has no money and sells the... | 256 megabytes | import java.util.Scanner;
public class test {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int x;
int c25=0;
int c50=0;
boolean s=true;
while(n--!=0){
x=in.nextInt();
if(s){
... | Java | ["4\n25 25 50 50", "2\n25 100", "4\n50 50 25 25"] | 2 seconds | ["YES", "NO", "NO"] | null | Java 8 | standard input | [
"implementation",
"greedy"
] | 63b20ab2993fddf2cc469c4c4e8027df | The first line contains integer n (1 ≤ n ≤ 105) — the number of people in the line. The next line contains n integers, each of them equals 25, 50 or 100 — the values of the bills the people have. The numbers are given in the order from the beginning of the line (at the box office) to the end of the line. | 1,100 | Print "YES" (without the quotes) if the booking clerk can sell a ticket to each person and give the change. Otherwise print "NO". | standard output | |
PASSED | f18cd887cf22d345887da39164813a95 | train_002.jsonl | 1380295800 | The new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the booking clerk sell a ticket to each person and give the change if he initially has no money and sells the... | 256 megabytes | import java.util.*;
public class Cin
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int a[]=new int[n];
int f=0;
int tf=0,fi=0;
for(int i=0;i<n;i++)
a[i]=sc.nextInt();
if(a[0]==50 || a[0]==100)
System.out.println("NO");
else{
for(int i=0;i<n;i++)... | Java | ["4\n25 25 50 50", "2\n25 100", "4\n50 50 25 25"] | 2 seconds | ["YES", "NO", "NO"] | null | Java 8 | standard input | [
"implementation",
"greedy"
] | 63b20ab2993fddf2cc469c4c4e8027df | The first line contains integer n (1 ≤ n ≤ 105) — the number of people in the line. The next line contains n integers, each of them equals 25, 50 or 100 — the values of the bills the people have. The numbers are given in the order from the beginning of the line (at the box office) to the end of the line. | 1,100 | Print "YES" (without the quotes) if the booking clerk can sell a ticket to each person and give the change. Otherwise print "NO". | standard output | |
PASSED | a4aed7dbbbfc82c177997ddbea2401e9 | train_002.jsonl | 1380295800 | The new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the booking clerk sell a ticket to each person and give the change if he initially has no money and sells the... | 256 megabytes | import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Arrays;
/**
* Test
*/
public class Test {
public static void main(String[] args) throws IOException {
int change = 0,n,bill,b25=0,b50=0;
... | Java | ["4\n25 25 50 50", "2\n25 100", "4\n50 50 25 25"] | 2 seconds | ["YES", "NO", "NO"] | null | Java 8 | standard input | [
"implementation",
"greedy"
] | 63b20ab2993fddf2cc469c4c4e8027df | The first line contains integer n (1 ≤ n ≤ 105) — the number of people in the line. The next line contains n integers, each of them equals 25, 50 or 100 — the values of the bills the people have. The numbers are given in the order from the beginning of the line (at the box office) to the end of the line. | 1,100 | Print "YES" (without the quotes) if the booking clerk can sell a ticket to each person and give the change. Otherwise print "NO". | standard output | |
PASSED | 044bc90a1382458b1f1946eaaa2146c8 | train_002.jsonl | 1380295800 | The new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the booking clerk sell a ticket to each person and give the change if he initially has no money and sells the... | 256 megabytes | import java.util.*;
public class Cinema
{
public static void main(String[]flkbjlb)
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int arr[]=new int[n];
int count1=0,count2=0,count3=0;
for(int i=0;i<n;i++)
{
arr[i]=sc.nextInt();
if(arr[i]==25)
{
count1++;
}
if(arr[i]==50)
{
... | Java | ["4\n25 25 50 50", "2\n25 100", "4\n50 50 25 25"] | 2 seconds | ["YES", "NO", "NO"] | null | Java 8 | standard input | [
"implementation",
"greedy"
] | 63b20ab2993fddf2cc469c4c4e8027df | The first line contains integer n (1 ≤ n ≤ 105) — the number of people in the line. The next line contains n integers, each of them equals 25, 50 or 100 — the values of the bills the people have. The numbers are given in the order from the beginning of the line (at the box office) to the end of the line. | 1,100 | Print "YES" (without the quotes) if the booking clerk can sell a ticket to each person and give the change. Otherwise print "NO". | standard output | |
PASSED | 9369252e39bfcbea3d5ea0e95015de60 | train_002.jsonl | 1380295800 | The new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the booking clerk sell a ticket to each person and give the change if he initially has no money and sells the... | 256 megabytes | import java.util.Scanner;
public class CInemaLine {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int testCase = sc.nextInt();
int countTwentyFive = 0;
int countFifty = 0;
boolean flag = true;
for(int i = 0 ; i < testCase ; i++){
int num = sc.nextInt();
i... | Java | ["4\n25 25 50 50", "2\n25 100", "4\n50 50 25 25"] | 2 seconds | ["YES", "NO", "NO"] | null | Java 8 | standard input | [
"implementation",
"greedy"
] | 63b20ab2993fddf2cc469c4c4e8027df | The first line contains integer n (1 ≤ n ≤ 105) — the number of people in the line. The next line contains n integers, each of them equals 25, 50 or 100 — the values of the bills the people have. The numbers are given in the order from the beginning of the line (at the box office) to the end of the line. | 1,100 | Print "YES" (without the quotes) if the booking clerk can sell a ticket to each person and give the change. Otherwise print "NO". | standard output | |
PASSED | 425bc16eaa98260a63b9b158ab42ae0c | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | import java.util.*;
public class Solution {
private static Scanner sc = new Scanner(System.in);
private static int[] a;
private static char[] s;
private static int n;
private static void readInt() {
a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
}
private static... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | 20b2c508398c85450933141387b6d47b | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | import java.util.*;
public class Equality
{
public static void main(String [] args) {
Scanner input = new Scanner(System.in);
int n = input.nextInt(), k = input.nextInt();
String str = input.next();
Set<Character> set = new HashSet<>();
for (int i = 0; i < str.length(); i++... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | 82ea07e850ca86574e12599236e9e0ab | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | import java.util.*;
public class equality
{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n=in.nextInt();
int k=in.nextInt();
String s=in.next();
Set<Character> set = new HashSet<>();
for(int i=0;i<n;i++)
{
set.add(s.charAt(i));
}
if(set.size()!=k)
{
Syste... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | 434c1c08c008cd902ed1ba6228c9e417 | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | import java.util.Scanner;
public class Equality_1038A {
public static void main(String[] args) {
// System.out.println("Hello world");
int[] alpabate = new int[26];
int n, k;
String s;
Scanner input = new Scanner(System.in);
n = input.nextInt();
k = input.nex... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | 9a5098190bd7f5349a51c130cebe5f6b | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | //package hello;
import java.util.*;
public class capitalization
{
public static void main(String args[])
{
Scanner scan = new Scanner(System.in);
int l,cnt;
l = scan.nextInt();
cnt = scan.nextInt();
String pattern ="";
while(pattern.length()==0) pattern = scan.nextLine();
int[] frequency = new int... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | cbe38201e6e5bfb6a448a1ff727f3925 | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | import java.util.*;
import java.math.*;
public class Submit {
public static void main(String[] args) {
Scanner kb=new Scanner(System.in);
String line=kb.nextLine();
String[] sp=line.split(" ");
int n=Integer.parseInt(sp[0]);
int k=Integer.parseInt(sp[1]);
String s=kb.nextLine();
int[] letterAppearances=... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | 709882efcfdf9d66b7150fc7f033aeba | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
int[] x=new int[b];
String s=sc.next();
for(int i=0;i<a;i++) {
for(int j=0;j<b;j++) {
if(s.charAt(i)==j+'A')
x[j]++;
}
}
Arrays.sort... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | 0a3eefdfcae35775e28b5f89734ddfce | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
// SHIVAM GUPTA :
//NSIT
//decoder_1671
//BEING PERFECTIONIST IS NOT AN OPTION
// ASCII = 48 + i ;
// SHIVAM GUPTA :
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
static PrintWriter out;... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | 399e728855c5d5c2531ce7b6ac270347 | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import static java.lang.Integer.min;
public class Helloworld {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String t... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | eba139bd224804a67ee77ff007d2f684 | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | import java.io.IOException;
import java.util.Arrays;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.StringTokenizer;
import static java.lang.Integer.min;
import static java.lang.Integer.parseInt;
public class Helloworld {
public static void merge(int arr[], int l, int m, int r)... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | 1e8866bd270de154396e5887d619ccf6 | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes |
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
public class Codechef {
static long substrings(String s) {
int n = s.length();
long sumofDigits[] = new long[n];
sumofDigits[0] = s.charAt(0) - '0';
long res = sumofDigits[0];
for (int i = 1; i < n; i++)... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | 2138e0d3f05f5f89a6e8d565c1049e2e | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | import java.util.*;
public class q
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int n,k,i,t=0;
char ch;
n=sc.nextInt();
k=sc.nextInt();
int a[]=new int[k];
String s=sc.next();
... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | 320c247854bd71c1b10f51624a7878ef | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class CP{
public static OutputStream out=new BufferedOutputStream(System.out);
static Scanner sc=new Scanner(System.in);
static long mod=1000000007l;
static int INF=1000000;
//nl-->neew line; //l-->line; //arp-->array print; //arpnl-->array ... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | 85322e255dc487d9e3d5279ab77f5ccf | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
Scanner in = new Sc... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | 98e5de1390bcb929203e5121fa57495f | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes |
import java.util.Arrays;
import java.util.Scanner;
public class Main{
public static void main(String [] args){
Scanner sc = new Scanner(System.in);
int n= sc.nextInt();
int k= sc.nextInt();
String s = sc.next();
int[] arr = new int [k];
for(int i=0;i<n;i++){
arr[s.charAt(i)-'A... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | df891373af0160af8c5971724380a401 | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;
imp... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | 3c291a892816b41a2ac755d09c66131a | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes |
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 GodOfWar
*/
public class String3 {
public static void main(String[] args) {
... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | ff4ce9aa47280480c96995960245974a | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | import java.util.Scanner;
import java.awt.image.BandedSampleModel;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class A {
public... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | ca9f32de154e6fa238925e1596ee6824 | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | import java.io.*;
import java.util.*;
public class problemA {
// private static final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
private static final Scanner in = new Scanner(System.in);
public static void main(String[] args) throws IOException {
int t = 1;
// ... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | 75edc3706fac775ccd8a7a41b95e1c52 | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class A
{
public static void process(int test_number)throws IOException
{
int n = ni(), k = ni(), freq[] = new int[k];
char arr[] = nln().toCharArray();
for(char c : arr)
freq[c - 'A']++;
int cnt = n;
for(int i : freq) cnt = Math.... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | 162fd916dae640898f6dfebd8e318445 | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Arrays;
import java.math.BigInteger;
/* 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.... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | d70769bcea97cf603498d51450b7bf8d | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | import java.util.Arrays;
import java.util.Scanner;
public class Main {
private static void findEquality(int size, int letters, String s) {
int[] arr = new int[letters];
for (int count = 0; count < size; count++)
arr[(int) s.charAt(count) - 65]++;
Arrays.sort(arr);
Syste... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | bab1dcf9cb10e2fba204f4af971f271f | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | import java.util.Scanner;
public class apples {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int n=in.nextInt();
int k=in.nextInt();
String s=in.next();
int A[]=new int[26];
for (int i=0; i<26; i++) A[i]=0;
for (int i=0; i<n; i++) A[s.charAt(i)-'A']++;
int ans=(int)1e9;
... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | e0712b83da6c60f6b5d5dff55e47a619 | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | import java.util.*;
public class Equality {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
Set<Integer> w=new HashSet<>();
int a=sc.nextInt();
int b=sc.nextInt();
String s=sc.next();
if(b==1 || a==2) {
System.out.println(a);
return;
}
int arr[]=new int[b];
int core... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | 7241157804887e950d7c3e44677ef40f | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes |
import java.io.*;
import java.math.*;
import java.util.*;
@SuppressWarnings("Duplicates")
// author @mdazmat9
public class Main{
static FastScanner sc = new FastScanner();
static PrintWriter out = new PrintWriter(System.out);
public static void main(String[] args) throws IOException {
int test = 1... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | 957b12ead97be372e4da129bd31183a0 | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | import java.util.*;
import java.io.*;
public class Equality {
public static void main(String[] args) {
MyScanner scn = new MyScanner();
out = new PrintWriter(new BufferedOutputStream(System.out));
// Start writing your solution here. -------------------------------------
/*
... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | 554577216d65a40c60305ed87b0a97d0 | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | import java.util.*;
public class Yash
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
int freq[] = new int[k];
String s = sc.next();
for(int i=0; i<s.length(); i++)
{
freq[s.charAt(i)-65]++;
}
int min = freq[0];
for(... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | 12a89bdc3b7da11d12f4165fc9f2ef49 | train_002.jsonl | 1536248100 | You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s... | 256 megabytes | // package cp;
import java.io.*;
import java.util.*;
public class Cf_three {
public static void main(String[] args) throws IOException {
PrintWriter out = new PrintWriter(System.out);
Readers.init(System.in);
int n=Readers.nextInt();
int k=Readers.nextInt();
String s=Readers.next();
int[] cnt=new int[k+1]... | Java | ["9 3\nACAABCCAB", "9 4\nABCABCABC"] | 2 seconds | ["6", "0"] | NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0... | Java 11 | standard input | [
"implementation",
"strings"
] | d9d5db63b1e48214d02abe9977709384 | The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet. | 800 | Print the only integer — the length of the longest good subsequence of string $$$s$$$. | standard output | |
PASSED | cde30a792275d95bce0b2378b9b438f5 | train_002.jsonl | 1530628500 | You are given three integers $$$n$$$, $$$d$$$ and $$$k$$$.Your task is to construct an undirected tree on $$$n$$$ vertices with diameter $$$d$$$ and degree of each vertex at most $$$k$$$, or say that it is impossible.An undirected tree is a connected undirected graph with $$$n - 1$$$ edges.Diameter of a tree is the max... | 256 megabytes | import java.io.*;
import java.util.*;
public class A {
public static void main(String[] args) throws IOException {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int d = scanner.nextInt();
int k = scanner.nextInt();
if (n < d + 1) {
System.... | Java | ["6 3 3", "6 2 3", "10 4 3", "8 5 3"] | 4 seconds | ["YES\n3 1\n4 1\n1 2\n5 2\n2 6", "NO", "YES\n2 9\n2 10\n10 3\n3 1\n6 10\n8 2\n4 3\n5 6\n6 7", "YES\n2 5\n7 2\n3 7\n3 1\n1 6\n8 7\n4 3"] | null | Java 8 | standard input | [
"constructive algorithms",
"graphs"
] | a4849505bca48b408a5e8fb5aebf5cb6 | The first line of the input contains three integers $$$n$$$, $$$d$$$ and $$$k$$$ ($$$1 \le n, d, k \le 4 \cdot 10^5$$$). | 2,100 | If there is no tree satisfying the conditions above, print only one word "NO" (without quotes). Otherwise in the first line print "YES" (without quotes), and then print $$$n - 1$$$ lines describing edges of a tree satisfying the conditions above. Vertices of the tree must be numbered from $$$1$$$ to $$$n$$$. You can pr... | standard output | |
PASSED | 92af9c31cdba21289a638050b684944b | train_002.jsonl | 1530628500 | You are given three integers $$$n$$$, $$$d$$$ and $$$k$$$.Your task is to construct an undirected tree on $$$n$$$ vertices with diameter $$$d$$$ and degree of each vertex at most $$$k$$$, or say that it is impossible.An undirected tree is a connected undirected graph with $$$n - 1$$$ edges.Diameter of a tree is the max... | 256 megabytes | import java.util.*;
import java.io.*;
public class _1003_E {
public static void main(String[] args) throws IOException {
int N = readInt(), D = readInt(), K = readInt();
if(D >= N || (D >= 2 && K == 1)) {println("NO"); exit();}
ArrayList<Integer> graph[] = new ArrayList[N+1]; for(int i = 1; i<=N; i++) graph[i]... | Java | ["6 3 3", "6 2 3", "10 4 3", "8 5 3"] | 4 seconds | ["YES\n3 1\n4 1\n1 2\n5 2\n2 6", "NO", "YES\n2 9\n2 10\n10 3\n3 1\n6 10\n8 2\n4 3\n5 6\n6 7", "YES\n2 5\n7 2\n3 7\n3 1\n1 6\n8 7\n4 3"] | null | Java 8 | standard input | [
"constructive algorithms",
"graphs"
] | a4849505bca48b408a5e8fb5aebf5cb6 | The first line of the input contains three integers $$$n$$$, $$$d$$$ and $$$k$$$ ($$$1 \le n, d, k \le 4 \cdot 10^5$$$). | 2,100 | If there is no tree satisfying the conditions above, print only one word "NO" (without quotes). Otherwise in the first line print "YES" (without quotes), and then print $$$n - 1$$$ lines describing edges of a tree satisfying the conditions above. Vertices of the tree must be numbered from $$$1$$$ to $$$n$$$. You can pr... | standard output | |
PASSED | baea5a658f812a116f21715d02ae9ef5 | train_002.jsonl | 1530628500 | You are given three integers $$$n$$$, $$$d$$$ and $$$k$$$.Your task is to construct an undirected tree on $$$n$$$ vertices with diameter $$$d$$$ and degree of each vertex at most $$$k$$$, or say that it is impossible.An undirected tree is a connected undirected graph with $$$n - 1$$$ edges.Diameter of a tree is the max... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Map;
import java.... | Java | ["6 3 3", "6 2 3", "10 4 3", "8 5 3"] | 4 seconds | ["YES\n3 1\n4 1\n1 2\n5 2\n2 6", "NO", "YES\n2 9\n2 10\n10 3\n3 1\n6 10\n8 2\n4 3\n5 6\n6 7", "YES\n2 5\n7 2\n3 7\n3 1\n1 6\n8 7\n4 3"] | null | Java 8 | standard input | [
"constructive algorithms",
"graphs"
] | a4849505bca48b408a5e8fb5aebf5cb6 | The first line of the input contains three integers $$$n$$$, $$$d$$$ and $$$k$$$ ($$$1 \le n, d, k \le 4 \cdot 10^5$$$). | 2,100 | If there is no tree satisfying the conditions above, print only one word "NO" (without quotes). Otherwise in the first line print "YES" (without quotes), and then print $$$n - 1$$$ lines describing edges of a tree satisfying the conditions above. Vertices of the tree must be numbered from $$$1$$$ to $$$n$$$. You can pr... | standard output | |
PASSED | 138ce9005778fd1ab62b3671656ce1a8 | train_002.jsonl | 1530628500 | You are given three integers $$$n$$$, $$$d$$$ and $$$k$$$.Your task is to construct an undirected tree on $$$n$$$ vertices with diameter $$$d$$$ and degree of each vertex at most $$$k$$$, or say that it is impossible.An undirected tree is a connected undirected graph with $$$n - 1$$$ edges.Diameter of a tree is the max... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String... | Java | ["6 3 3", "6 2 3", "10 4 3", "8 5 3"] | 4 seconds | ["YES\n3 1\n4 1\n1 2\n5 2\n2 6", "NO", "YES\n2 9\n2 10\n10 3\n3 1\n6 10\n8 2\n4 3\n5 6\n6 7", "YES\n2 5\n7 2\n3 7\n3 1\n1 6\n8 7\n4 3"] | null | Java 8 | standard input | [
"constructive algorithms",
"graphs"
] | a4849505bca48b408a5e8fb5aebf5cb6 | The first line of the input contains three integers $$$n$$$, $$$d$$$ and $$$k$$$ ($$$1 \le n, d, k \le 4 \cdot 10^5$$$). | 2,100 | If there is no tree satisfying the conditions above, print only one word "NO" (without quotes). Otherwise in the first line print "YES" (without quotes), and then print $$$n - 1$$$ lines describing edges of a tree satisfying the conditions above. Vertices of the tree must be numbered from $$$1$$$ to $$$n$$$. You can pr... | standard output | |
PASSED | 25c47282d79ffd451744e332ff4fb19f | train_002.jsonl | 1530628500 | You are given three integers $$$n$$$, $$$d$$$ and $$$k$$$.Your task is to construct an undirected tree on $$$n$$$ vertices with diameter $$$d$$$ and degree of each vertex at most $$$k$$$, or say that it is impossible.An undirected tree is a connected undirected graph with $$$n - 1$$$ edges.Diameter of a tree is the max... | 256 megabytes | import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
import static java.lang.Math.*;
import java.util.concurrent.ThreadLocalRandom;
public class Sol implements Runnable {
long mod = (long)1e9 + 7;
class pair {
int x, y;
pair(int X, int Y) {
x = X;
y = ... | Java | ["6 3 3", "6 2 3", "10 4 3", "8 5 3"] | 4 seconds | ["YES\n3 1\n4 1\n1 2\n5 2\n2 6", "NO", "YES\n2 9\n2 10\n10 3\n3 1\n6 10\n8 2\n4 3\n5 6\n6 7", "YES\n2 5\n7 2\n3 7\n3 1\n1 6\n8 7\n4 3"] | null | Java 8 | standard input | [
"constructive algorithms",
"graphs"
] | a4849505bca48b408a5e8fb5aebf5cb6 | The first line of the input contains three integers $$$n$$$, $$$d$$$ and $$$k$$$ ($$$1 \le n, d, k \le 4 \cdot 10^5$$$). | 2,100 | If there is no tree satisfying the conditions above, print only one word "NO" (without quotes). Otherwise in the first line print "YES" (without quotes), and then print $$$n - 1$$$ lines describing edges of a tree satisfying the conditions above. Vertices of the tree must be numbered from $$$1$$$ to $$$n$$$. You can pr... | standard output | |
PASSED | 65d428361e102bc7d0c8fd81573d570c | train_002.jsonl | 1530628500 | You are given three integers $$$n$$$, $$$d$$$ and $$$k$$$.Your task is to construct an undirected tree on $$$n$$$ vertices with diameter $$$d$$$ and degree of each vertex at most $$$k$$$, or say that it is impossible.An undirected tree is a connected undirected graph with $$$n - 1$$$ edges.Diameter of a tree is the max... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Collection;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Queue;
import java.util.LinkedList;
import java.io.InputStream;
/**
* Built using CHelper ... | Java | ["6 3 3", "6 2 3", "10 4 3", "8 5 3"] | 4 seconds | ["YES\n3 1\n4 1\n1 2\n5 2\n2 6", "NO", "YES\n2 9\n2 10\n10 3\n3 1\n6 10\n8 2\n4 3\n5 6\n6 7", "YES\n2 5\n7 2\n3 7\n3 1\n1 6\n8 7\n4 3"] | null | Java 8 | standard input | [
"constructive algorithms",
"graphs"
] | a4849505bca48b408a5e8fb5aebf5cb6 | The first line of the input contains three integers $$$n$$$, $$$d$$$ and $$$k$$$ ($$$1 \le n, d, k \le 4 \cdot 10^5$$$). | 2,100 | If there is no tree satisfying the conditions above, print only one word "NO" (without quotes). Otherwise in the first line print "YES" (without quotes), and then print $$$n - 1$$$ lines describing edges of a tree satisfying the conditions above. Vertices of the tree must be numbered from $$$1$$$ to $$$n$$$. You can pr... | standard output | |
PASSED | b912cb3f7b149780874b3f283f94c5c2 | train_002.jsonl | 1530628500 | You are given three integers $$$n$$$, $$$d$$$ and $$$k$$$.Your task is to construct an undirected tree on $$$n$$$ vertices with diameter $$$d$$$ and degree of each vertex at most $$$k$$$, or say that it is impossible.An undirected tree is a connected undirected graph with $$$n - 1$$$ edges.Diameter of a tree is the max... | 256 megabytes | import java.util.*;
public class CF1003E {
private static List<int[]> links = new ArrayList<>();
private static class Node {
public int id;
public int distance;
public int degree;
public Node(int id, int distance, int degree) {
this.id = id;
this.dista... | Java | ["6 3 3", "6 2 3", "10 4 3", "8 5 3"] | 4 seconds | ["YES\n3 1\n4 1\n1 2\n5 2\n2 6", "NO", "YES\n2 9\n2 10\n10 3\n3 1\n6 10\n8 2\n4 3\n5 6\n6 7", "YES\n2 5\n7 2\n3 7\n3 1\n1 6\n8 7\n4 3"] | null | Java 8 | standard input | [
"constructive algorithms",
"graphs"
] | a4849505bca48b408a5e8fb5aebf5cb6 | The first line of the input contains three integers $$$n$$$, $$$d$$$ and $$$k$$$ ($$$1 \le n, d, k \le 4 \cdot 10^5$$$). | 2,100 | If there is no tree satisfying the conditions above, print only one word "NO" (without quotes). Otherwise in the first line print "YES" (without quotes), and then print $$$n - 1$$$ lines describing edges of a tree satisfying the conditions above. Vertices of the tree must be numbered from $$$1$$$ to $$$n$$$. You can pr... | standard output | |
PASSED | 91a600c96732400c060b4927fd3e8515 | train_002.jsonl | 1557844500 | You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$... | 256 megabytes | //package com.netease.music.codeforces.round560.div3;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
/**
* Created by dezhonger on 2019/5/14
*/
public class E {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
... | Java | ["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"] | 2 seconds | ["646", "757402647", "20"] | null | Java 8 | standard input | [
"sortings",
"greedy",
"math"
] | 93431bdae447bb96a2f0f5fa0c6e11e0 | The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of... | 1,600 | Print one integer — the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder. | standard output | |
PASSED | c70559d8b7c776a3191a278db340b1a2 | train_002.jsonl | 1557844500 | You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOExcept... | Java | ["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"] | 2 seconds | ["646", "757402647", "20"] | null | Java 8 | standard input | [
"sortings",
"greedy",
"math"
] | 93431bdae447bb96a2f0f5fa0c6e11e0 | The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of... | 1,600 | Print one integer — the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder. | standard output | |
PASSED | 622e7fae73bc8a04eeeb667eb013a72f | train_002.jsonl | 1557844500 | You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$... | 256 megabytes | import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
static final long MOD = 998244353;
//static final long MOD = 1000000007;
static boolean[] visited;
public static void main(String[] args) throws IOException {
FastScanner sc = new FastScanner();
int N = sc.nextInt();... | Java | ["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"] | 2 seconds | ["646", "757402647", "20"] | null | Java 8 | standard input | [
"sortings",
"greedy",
"math"
] | 93431bdae447bb96a2f0f5fa0c6e11e0 | The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of... | 1,600 | Print one integer — the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder. | standard output | |
PASSED | 1937254b47f64b60d9f1b07e8c65bf47 | train_002.jsonl | 1557844500 | You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Random;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in Actual solution is at th... | Java | ["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"] | 2 seconds | ["646", "757402647", "20"] | null | Java 8 | standard input | [
"sortings",
"greedy",
"math"
] | 93431bdae447bb96a2f0f5fa0c6e11e0 | The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of... | 1,600 | Print one integer — the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder. | standard output | |
PASSED | 88cb2fd2f0999c724086cb12a47eb014 | train_002.jsonl | 1557844500 | You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$... | 256 megabytes | /*
https://codeforces.com/contest/1165/problem/E
*/
import java.util.*;
import java.io.*;
public class x1165E
{
public static final long MOD = 998244353L;
public static void main(String args[]) throws Exception
{
BufferedReader infile = new BufferedReader(new InputStreamReader(System.i... | Java | ["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"] | 2 seconds | ["646", "757402647", "20"] | null | Java 8 | standard input | [
"sortings",
"greedy",
"math"
] | 93431bdae447bb96a2f0f5fa0c6e11e0 | The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of... | 1,600 | Print one integer — the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder. | standard output | |
PASSED | 90094993074126cd80f8f5f80c74342b | train_002.jsonl | 1557844500 | You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$... | 256 megabytes | // Working program using Reader Class
import java.io.*;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main
{
static class Reader
{
final private int BUFFER_SIZE = 1 << 16;
private DataInput... | Java | ["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"] | 2 seconds | ["646", "757402647", "20"] | null | Java 8 | standard input | [
"sortings",
"greedy",
"math"
] | 93431bdae447bb96a2f0f5fa0c6e11e0 | The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of... | 1,600 | Print one integer — the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder. | standard output | |
PASSED | a163a768484427c229a8680b192b9e48 | train_002.jsonl | 1557844500 | You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$... | 256 megabytes | import java.io.*;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
@SuppressWarnings("Duplicates")
public class test {
FastScanner in;
PrintWriter out;
boolean systemIO = true;
int INF = Integer.MAX_VALUE / 2;
long mod = 998244353;
void solve() {
int n = in.nextInt()... | Java | ["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"] | 2 seconds | ["646", "757402647", "20"] | null | Java 8 | standard input | [
"sortings",
"greedy",
"math"
] | 93431bdae447bb96a2f0f5fa0c6e11e0 | The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of... | 1,600 | Print one integer — the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder. | standard output | |
PASSED | 039b7bc6be93a36a637036bd33dc6e5c | train_002.jsonl | 1557844500 | You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;
public class fast implements Runnable {
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChar... | Java | ["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"] | 2 seconds | ["646", "757402647", "20"] | null | Java 8 | standard input | [
"sortings",
"greedy",
"math"
] | 93431bdae447bb96a2f0f5fa0c6e11e0 | The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of... | 1,600 | Print one integer — the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder. | standard output | |
PASSED | ed352401b40f21a6c1faa7702be259d6 | train_002.jsonl | 1557844500 | You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class E_TwoArraysAndSumOfFunctions {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader inp = new InputReader(inputStream);
PrintWriter out = new PrintWriter(o... | Java | ["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"] | 2 seconds | ["646", "757402647", "20"] | null | Java 8 | standard input | [
"sortings",
"greedy",
"math"
] | 93431bdae447bb96a2f0f5fa0c6e11e0 | The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of... | 1,600 | Print one integer — the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder. | standard output | |
PASSED | 1ddf9d1e34968a5dcd9e93b44589354d | train_002.jsonl | 1557844500 | You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$... | 256 megabytes | import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
/**
* Created by tech4GT on 5/21/19.
*/
public class twoArrays {
private static final long M = 998244353L;
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
... | Java | ["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"] | 2 seconds | ["646", "757402647", "20"] | null | Java 8 | standard input | [
"sortings",
"greedy",
"math"
] | 93431bdae447bb96a2f0f5fa0c6e11e0 | The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of... | 1,600 | Print one integer — the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder. | standard output | |
PASSED | 18e5f6f91ff6f743378cf6664f59e746 | train_002.jsonl | 1557844500 | You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$... | 256 megabytes | import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;
public class ProblemE {
public static InputStream inputStream = System.in;
public static OutputStream outputStream = System.out;
public static void main(String[] args) {
... | Java | ["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"] | 2 seconds | ["646", "757402647", "20"] | null | Java 8 | standard input | [
"sortings",
"greedy",
"math"
] | 93431bdae447bb96a2f0f5fa0c6e11e0 | The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of... | 1,600 | Print one integer — the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder. | standard output | |
PASSED | 6156e025de9b00c326702174c235a740 | train_002.jsonl | 1557844500 | You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
public class S {
static class Pair implements Comparable<Pair>{
long val;
int ind;
public Pair(long x,int y){val=x;ind=y;}
public Pair(){}
public int compareTo(Pair p){
long r = val - p.val;
if(r==0)return 0;
if(r>0)return... | Java | ["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"] | 2 seconds | ["646", "757402647", "20"] | null | Java 8 | standard input | [
"sortings",
"greedy",
"math"
] | 93431bdae447bb96a2f0f5fa0c6e11e0 | The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of... | 1,600 | Print one integer — the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder. | standard output | |
PASSED | 53f045ed0634112c9c7d2f056ddc87e5 | train_002.jsonl | 1557844500 | You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$... | 256 megabytes |
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.Comparator;
import java.util.HashSet;
import java.util.InputMismatchEx... | Java | ["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"] | 2 seconds | ["646", "757402647", "20"] | null | Java 8 | standard input | [
"sortings",
"greedy",
"math"
] | 93431bdae447bb96a2f0f5fa0c6e11e0 | The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of... | 1,600 | Print one integer — the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder. | standard output | |
PASSED | a93937b719d18d2c3dfa99d21258df9e | train_002.jsonl | 1557844500 | You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$... | 256 megabytes | /*
* 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.
*/
//package Lost;
import java.io.*;
import java.util.*;
public class E1165
{
public static void main(String args[])throws IOExceptio... | Java | ["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"] | 2 seconds | ["646", "757402647", "20"] | null | Java 8 | standard input | [
"sortings",
"greedy",
"math"
] | 93431bdae447bb96a2f0f5fa0c6e11e0 | The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of... | 1,600 | Print one integer — the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder. | standard output | |
PASSED | ffc6a27b68f8ec032439bbaae71aa6ac | train_002.jsonl | 1557844500 | You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$... | 256 megabytes | import java.util.*;
import java.math.*;
public class Main {
public static void merge(long[] arr, int l, int m, int r) {
int n1 = m - l + 1;
int n2 = r - m;
long[] L = new long[n1];
long[] R = new long[n2];
for (int i = 0; i < n1; i++) {
L[i] = arr[l + i];
... | Java | ["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"] | 2 seconds | ["646", "757402647", "20"] | null | Java 8 | standard input | [
"sortings",
"greedy",
"math"
] | 93431bdae447bb96a2f0f5fa0c6e11e0 | The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of... | 1,600 | Print one integer — the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder. | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.