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
58b6224d2585e6d6e708331e29df52a4
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; import java.text.*; public class Main{ public static void main(String args[]) throws IOException{ Read sc=new Read(); int t=sc.nextInt(); for(int i=0;i<t;i++){ int n=sc.nextInt(); int q=sc.nextInt(); ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 17
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
2ef61c121eb5765581c2bd3a73dad4f2
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; import java.awt.*; public class Main { public static void main(String[] args) throws IOException { var in=new FastInput(); StringBuffer res=new StringBuffer(); var t=in.getIntArray(1)[0]; for (int i = 0; i < ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 17
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
b06faecc8ce57392b4adad929c4da195
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.*; import java.io.*; public class Template { FastScanner in; PrintWriter out; Random rnd = new Random(); final int MAX_VAL = (1<<31) - 1; int rndInt() { return rnd.nextInt(MAX_VAL); } public void solve() throws IOException { int t = in.nextInt(); f...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 17
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
79c8a64e8d5bec676f7da0e89636cf29
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class CF1722E extends PrintWriter { CF1722E() { super(System.out); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF1722E o = new CF1722E(); o.main(); o.flush(); } static final int A = 1000; void main() { int t = sc.nextInt(); whil...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 17
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
4052dc7e091214f5ccd913c3ebd6289f
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public final class Main{ static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); }...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
15b94450a3f407ddfb0f5498661403dd
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.TreeSet; import...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
2e1bc21de6881596992fcf127f6100aa
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.*; import java.util.StringTokenizer; public class copy { static int log=30; static int[][] ancestor; static int[] depth; static void sieveOfEratosthenes(int n, ArrayList<Integer> arr) { boolean prime[] = new boolean...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
bfdbf5da74438f296da861669b0fa320
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; import static java.util.Collections.swap; public class Solver { public static void main(String[] args) throws IOException { int t = nextInt(); long[][] mass; long[][] mass1; for (int i = 0; i < t; i++) { mass = new long...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
bd651014d662e88ae0abbad90bb8b698
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { static void read(int arr[], int start, int end, FastReader in) { for (int i = start; i < end; i++) { arr[i] = in.nextInt(); } } static int sumArr(int arr[]) { int sum = 0; ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
5904a6e54c506814d4e97327046410ec
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
/*LoudSilence*/ import java.io.*; import java.util.*; import static java.lang.Math.*; public class Solution { /*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ static FastScanner ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
46cdfb1655b5f2f6fa9665ecc4ddce3e
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
/*LoudSilence*/ import java.io.*; import java.util.*; import static java.lang.Math.*; public class Solution { /*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ static FastScanner ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
11e0760bf2ce611eb50d5d34beb2cd30
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.lang.invoke.MethodHandles; import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
da41b330981087aec4a40f9b347f82b7
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class _1722E { public static void main(String[] args) { // TODO Auto-generated method stub // Test case template Scanner sc = new Scanner(System.in); int cases=sc.nextInt(); while(cases--!=0) { //For every Testcase int n=sc.nextI...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
c3ecfb59a3c91f9775c37b3ba76f2715
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.Scanner; public class CountingRectangles2{ public static void main(String[] args) { Scanner in = new Scanner(System.in); int inputs = in.nextInt(); for (int i = 0; i < inputs; i++) { int rectangles = in.nextInt(); int queries = in.nextInt()...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
bbb50f8bdf503c73904d9734fcc9dd2b
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
/* _oo0oo_ o8888888o 88" . "88 (| -_- |) 0\ = /0 ___/`---'\___ .' \\| |// '. / \\||| : |||// \ / _||||| -:- |||||- \ ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
13d22476195dc22b2f1ce37ed7c8542b
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.StringTokenizer; import java.util.*; public class School { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int t= sc.nextInt(); while(t-->0){ int n=sc.nextInt(); int q= sc.nextInt()...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
9d6ed2b02193ff50f195b837b180beef
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { static int globalVariable = 123456789; static String author = "pl728 on codeforces"; public static void main(String[] args) { FastReader sc = new FastReader(); ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
50ad79fa9f30d43e007912414ed714f5
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class Codeforces { static FastReader f = new FastReader(); public static PrintWriter out = new PrintWriter(System.out); static int primes[]; static int dp1[][]; static long ans = 0; static List<List<Integer>> adj = new ArrayList<>(); static int up[][] = new int[2...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
8dd72863d23d3a02d9a4529f73f42f87
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { static AReader scan = new AReader(); static int N = 1010; static long[][] g = new long[N][N]; static long get(int x1,int x2,int y1,int y2){ if(x2 < ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
02743f4cd8e4500cecd448676b4addf5
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.*; import java.io.*; import static java.lang.Math.*; public class Main { static InputStream is; static PrintWriter out; static String INPUT = ""; static final int ima = Integer.MAX_VALUE, imi = Integer.MIN_VALUE; static final long lma = Long.MAX_VALUE, lmi = Long...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
b25ebfeb95ad7188caedf52d360eb756
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.*; import java.io.*; import static java.lang.Math.*; public class Main { static InputStream is; static PrintWriter out; static String INPUT = ""; static final int ima = Integer.MAX_VALUE, imi = Integer.MIN_VALUE; static final long lma = Long.MAX_VALUE, lmi = Long...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
945e321232e990b3ba5c9892f124c363
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.Scanner; import java.util.TreeMap; public class E2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(; t>0; t--) { int n = sc.nextInt(); int q = sc.nextInt(); long[][] ma...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
b3d169a3ceebeb349c9a72a0b91cabae
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static int INF = 0x3f3f3f3f, mod = 1000000007, mod9 = 998244353; public static void main(String args[]){ try { PrintWriter o = new PrintWriter(System.out); boolean multiTest = true; // init ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
11a2bf18dbc34d43af6b32eae2d4a090
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static int INF = 0x3f3f3f3f, mod = 1000000007, mod9 = 998244353; public static void main(String args[]){ try { PrintWriter o = new PrintWriter(System.out); boolean multiTest = true; // init ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
30159ce91010b79f0b0e6c5c7a17a811
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static int INF = 0x3f3f3f3f, mod = 1000000007, mod9 = 998244353; public static void main(String args[]){ try { PrintWriter o = new PrintWriter(System.out); boolean multiTest = true; // init ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
baf87a3a881571dbf16bdc67577efe70
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.Scanner; public class CountingRectangles { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- != 0) { int n = sc.nextInt(); int q = sc.nextInt(); long[][] f = new long[1000][1000]; for (int i = 0; i < n; ++i)...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
019f7f706e4b6ed7727b3650f7742ddb
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class countingrectangles { public static void main(String[] args) throws IOException { Reader in = new Reader(); PrintWriter out = new PrintWriter(System.out); int t = in.nextInt(); for(int z = 0; z < t; z++) { long[][] arr = ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
e73d54b185237fb7d0e3363148998bed
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.math.BigDecimal; import java.util.*; public class Main{ static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out)); static StreamTokenizer st = new StreamTokenizer(bf); ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
2ac9a571db32dd536af07f2d3eba20bc
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.*; import java.io.*; public class codeforces { public static void main(String[] args) { FastReader in = new FastReader(); int t = in.nextInt(); while(t-->0) { int n = in.nextInt(); int q = in.nextInt(); long[][] dp = new long[1001][1001]; ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
ebb7404c76b26cc2c56fc98402226b0d
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.*; import java.io.*; public class Main { static ContestScanner sc = new ContestScanner(System.in); static PrintWriter pw = new PrintWriter(System.out); static StringBuilder sb = new StringBuilder(); public static void main(String[] args) throws Exception { int T = sc....
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
eddd910ca6ecc99b7c40aa84d4d61be3
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.*; import java.io.*; public class e { //FastReader public static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
06dc557527d122b677c9c51542669e3d
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.Scanner; public class Solution{ public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); while(t-- > 0){ int n = scanner.nextInt(); int q = scanner.nextInt(); int max = 1005; ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
595274028072082f1718fc8da20ac52d
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.sort; public class Codeforces { public static void main(String[] args) { FastReader fastReader = new ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
936b62975445efaca72a316a6dcb815f
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Ide { public static void main (String[] args) throws java.lang.Exception { // your code goes here BufferedReader br = ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
bf518bee6896d71dbb41c69682a191d5
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
//codeforces //package someAlgorithms; import java.util.*; import java.io.*; import java.lang.*; import java.io.File; public class Main { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
74b22f7af12a79941070fe99024affa5
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.*; import java.io.*; public class Main { static StringBuilder sb; static dsu dsu; static long fact[]; static int mod = (int) (1e9 + 7); static void print(int[]arr){ for(int i=0;i<arr.length;i++)System.out.print(arr[i]+" "); System.out.println(); } static void print(long[]arr){ ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
dc10ffaf4c012369a25af0b00047707a
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class E { static class FastScanner { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st=new StringTokenizer(""); ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
aaeb976ef08da55599d29cc8cc24a67a
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Random; import java.util.StringTokenizer; import java.util.concurrent.ThreadLocalRandom; /* 3 2 1 4 3 1 4 2 //1 3 4 2 1 //2 4 2 1 3 //3 000 001 010 011 100 101 110 111 1 2 3 4 5 6 1 3 6 10 15 21 */ pu...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
74b733329a93b261a9c8f5cc5604e943
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.*; import java.io.*; public class Main { static int[] parent, size; public static void main(String[] args) throws IOException { int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); int q = sc.nextInt(); long[][] arr = new...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
a7743f9b0abc31fa0c772386907dbef4
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
// package FirstPackage; import java.util.*; import java.lang.Math; import java.io.* ; public class Account { public static class Pair<Object1 ,Object2> { Object1 key ; Object2 val ; Pair(Object1 key ,Object2 val) { this.key = key ; this.val = val ; ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
00440f86222627ba42654b8cf6b88e99
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
/* Author: Spidey2182 #: 1722E */ import java.util.*; public class CountingRectangles implements Runnable { static ContestScanner sc = new ContestScanner(); static ContestPrinter out = new ContestPrinter(); public static void main(String[] args) { new Thread(null, new Counti...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
f212bf85350a970fd2c195873f1565ff
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
// 17-05 // import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class D { static int N = 1000; static long hw[][]; public static void main(String[] args) { Scanner sc = new Scanner(); ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
05f3a9c3a88ba1f28214128faffd3201
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; public class Main { static long ans; public static void main(String arg[]) throws IOException { BufferedReader br = new Bu...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
e8da1925875e175d76c6f7d1a2b62629
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } String next() { ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
77fd6684af4f9c7bc95b32b070ad92f5
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
// JAI SHREE RAM, HAR HAR MAHADEV, HARE KRISHNA import java.util.*; import java.util.Map.Entry; import java.util.stream.*; import java.lang.*; import java.math.BigInteger; import java.text.DecimalFormat; import java.io.*; public class CodeForces { static private final String INPUT = "input.txt"; s...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
29bfc522074bb770375e947f8715431d
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.BufferedReader; import java.io.*; import java.io.InputStreamReader; import java.util.Scanner; import java.util.*; public class Yoo { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new Buffe...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
c59d8ed1ad512febd3da40791d56e317
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class Counting_Rectangles { static FastScanner fs; static FastWriter fw; static boolean checkOnlineJudge = System.getProperty("ONLINE_JUDGE") == null; private static final int[][] kdir = new int[][]{{-1, 2}, {-2, 1}, {-2, -1}, {-1, -2}, {1, -2}, {...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
e304276adba76dcb4b1cd5aab8f96e91
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.lang.invoke.MethodHandles; import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
a7824ef43b98b19bafd3e3fb037c713a
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class E { static PrintWriter out; static Kioken sc; static boolean checkOnlineJudge = System.getProperty("ONLINE_JUDGE") == null; public static void main(String[] args) throws FileNotFoundException { if (checkOnlineJudge) { out...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
4c349198ac5d5cad0858020f9df5ace0
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import java.util.*; import java.io.*; import java.math.*; public class E_Counting_Rectangles { static long mod = Long.MAX_VALUE; public static void main(String[] args) { OutputStream ou...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
ce606f4aa6150879e946f351a5c336b6
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; // @author : Dinosparton public class test { static class Pair{ long x; int y; Pair(long x,int y){ this.x = x; this.y = y; } } static class Compare { ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
0ffccf9749b713dbdaee48cb434c1ece
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
/* "Everything in the universe is balanced. Every disappointment you face in life will be balanced by something good for you! Keep going, never give up." Just have Patience + 1... */ import java.util.*; import java.lang...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
3bd294889344b4d32b98104524abc2e4
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.*; import java.io.*; public class F{ static FastScanner fs = null; public static void main(String[] args) { fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int t = fs.nextInt(); while(t-->0){ int n = fs.nextInt(); int q = fs.nextInt(); long ar[][] = ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
90abe61b1506f737254abbf509f06acf
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
///WizardAP - 当你休息的时候,很多人比你付出更多的努力!不放弃 ! /// Time : 2022-10-12, Wed, 16:30 import java.io.*; import java.util.*; import static java.lang.Double.parseDouble; import static java.lang.System.in; import static java.lang.System.out; public class Main { static final int MOD = (int) 1e9 + 7; public static void ma...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
2e21d6a413548876e3629ae1d12b35fd
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.StringTokenizer; public class Counting_Rectangles{ static long [][]prefix; public static void main(String[]args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int t = sc.nextInt(); ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
7c6c299141aad39de88e2ca4079e0be7
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class Main { static int T; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); StringTokenizer st = new StringTokenize...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
3579c830c9b6fea4b99f9e82e6d616bc
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public final class Main{ static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); }...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
ea9cb63506712b0249f3a089f82d4ce9
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import javax.print.attribute.IntegerSyntax; import java.util.*; import java.io.*; public class Solution { private static class FastIO { private static class FastReader { BufferedReader br; StringTokenizer st; FastReader() { ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
67cd08c9216c3c2ef307bc60450babf8
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import javax.print.DocFlavor; import java.util.*; import java.io.*; public class Main { static String ss, io[]; static int test = 1, n, m, N = 100010; static long[][] a = new long[1001][1001], ps = new long[1001][1001]; static void solve() throws IOException{ n = ni(); m = ni(); ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
76d5ca9af8527153aa8d427f134964ea
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
//package com.rajan.codeforces.contests.contest817; import java.io.*; public class ProblemE { private static int MAX = 1001; public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter writer = new Bu...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
0205d42182b8f19ad70875d3151c31da
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class File { public static void main(String args[]) { FastScanner fs = new FastScanner(); int testcases = fs.nextInt(); while(testcases-- > 0) { ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
cb949f63924a54a3d78af613a85f7a17
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class E_Counting_Rectangles { public static void s() { int n = sc.nextInt(), q = sc.nextInt(); long[][] rmap = new long[1002][1002]; for(int i=0; i<n; i++) { ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
649b817145ebe835ae5d3e5d30b0d5d0
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
/* بسم الله الرحمن الرحيم /$$$$$ /$$$$$$ /$$ /$$ /$$$$$$ |__ $$ /$$__ $$ |$$ |$$ /$$__ $$ | $$| $$ \ $$| $$|$...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
6bb5f538a63dd50b345d3e8f911ea239
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
//package random; import java.util.*; import java.io.*; public class CF { public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int q = Integer.parseInt(br.readLine()); while(q-->0) { StringTokenizer st = new StringTokenizer(...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
2e3628a99c413bc04a568dffd151552c
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.util.*; public class Submit { public static void main(String[] args) { solve(); } private static void solve() { FastReader sc = new FastReader(); int t = sc.nextInt(); while (t-- > 0) { ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
0944d01b31a570cd3295e95db3af6086
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.TreeSet; import...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
3ff8ca99afb25e7fb8362edfdabbd11a
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; import java.math.RoundingMode; import java.util.*; import java.util.concurrent.LinkedBlockingDeque; import java.io.FileWriter; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; // graph, dfs,bfs,...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
70d19654a080641fd5b03d3819174ceb
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
//Some of the methods are copied from GeeksforGeeks Website import java.util.*; import java.lang.*; import java.io.*; @SuppressWarnings("unchecked") public class E_Counting_Rectangles { //static Scanner sc=new Scanner(System.in); //static Reader sc=new Reader(); static FastReader sc=new FastReader(S...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
b72a64b245a19123bde779b65cfa15b3
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
/* KEEP CALM AND जय श्री राम * A B C D are easy just dont give up , you can do it! * FIRST AND VERY IMP -> READ AND UNDERSTAND THE QUESTION VERY CAREFULLY. * WARNING -> DON'T CODE BULLSHIT , ALWAYS CHECK THE LOGIC ON MULTIPLE TESTCASES AND EDGECASES BEFORE. * SECOND -> TRY TO FIND RELEVENT PATTERN SMARTLY. * WARNI...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
ddad434243eedd82818b469989fa0435
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class CodeForces { public static void main (String[] args) throws java.lang.Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); PrintWriter out=new PrintWriter(System.out); int testCases=Integer.parseInt(...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
564b03611979ce8ac9b64f362d5f2425
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import j...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
03351323775fbb63e18e84d4e62983c3
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class Main { static FastReader scanner = new FastReader(); public static void solve() { int TARGET = 1001; int n = scanner.nextInt(); int q = scanner.nextInt(); long[][] arr = new long[TARGET][TARGET]; for(in...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
0f26a41a4712b534c1a9910666f5ec4b
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class Main { final static int mod = 998244353; // final static int mod = (int)1e9+7; static boolean[] prime = new boolean[1]; static int[][] dir1 = new int[][]{{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; static int[][] dir2 = new int[][]{{0, 1}, {0, -1}, {1...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
c30b109848ab8bdeaed38b325d2b5489
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
// package c1722; // // Codeforces Round #817 (Div. 4) 2022-08-30 07:50 // E. Counting Rectangles // https://codeforces.com/contest/1722/problem/E // time limit per test 6 seconds; memory limit per test 256 megabytes // public class Pseudo for 'Source should satisfy regex [^{}]*public\s+(final)?\s*class\s+(\w+).*' // ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
c94ceb36e3bd0e4eeaa42ddcdde3ee69
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class E { static IOHandler sc = new IOHandler(); static long [] bit; public static void main(String[] args) { // TODO Auto-generated method stub int testCases = sc.nextInt(); for (int i = 1; i <= testCases; ++i) { solve(i); } } pr...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
55c91874eb960a7bbd37fd8c258e48c1
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class Main { static Reader r = new Reader(); static StringBuilder sb = new StringBuilder(); static long cnt[][]; public static void main(String args[]) throws IOException { int t = r.readInt(); while(t-->0){ solve(); ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
2e9621e906e0b85262a8930188226d65
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.lang.*; import java.util.*; public class ComdeFormces { static int dp[][]; static boolean mnans; static int x[]= {-1,0,0,1}; static int y[]= {0,-1,1,0}; static int ans[]; public static void main(String[] args) throws Exception{ // TODO Auto-generated method stub FastR...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
a7bba71fc406b348e4a5dfddcbf194e1
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class R817E { public static void main(String[] args) { JS scan = new JS(); int t = scan.nextInt(); while(t-->0){ int n = scan.nextInt(); int q = scan.nextInt(); long[][] freq = new long[1001][1001]; ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
71b493e3975eb853f0f300bb258c32c7
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
// JAI SHREE RAM, HAR HAR MAHADEV, HARE KRISHNA import java.util.*; import java.util.Map.Entry; import java.util.stream.*; import java.lang.*; import java.math.BigInteger; import java.text.DecimalFormat; import java.io.*; public class CodeForces { static private final String INPUT = "input.txt"; s...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 11
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
caf49feb6999be0b2f345d0d95257143
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class CountingRectangles { private static final int START_TEST_CASE = 1; private static final int H_MAX = 1000; private static final int W_MAX = 1000; public static void solveCase(FastIO io, int testCase) { final int N = io.nextInt(); final int Q = io.n...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 8
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
2dff6ea4625df783c7aade39a3a86c67
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class CountingRectangles { private static final int START_TEST_CASE = 1; private static final int H_MAX = 1000; private static final int W_MAX = 1000; public static void solveCase(FastIO io, int testCase) { final int N = io.nextInt(); final int Q = io...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 8
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
7b394ccca13db5f4618d439c81d22dc9
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class CountingRectangles { private static final int START_TEST_CASE = 1; public static void solveCase(FastIO io, int testCase) { final int N = io.nextInt(); final int Q = io.nextInt(); IntQuadTree qt = new IntQuadTree(1, 1000, 1, 1000); for (in...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 8
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
1f0b328436fb88b0b7cdde9eeaef6372
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class CountingRectangles { private static final int START_TEST_CASE = 1; public static void solveCase(FastIO io, int testCase) { final int N = io.nextInt(); final int Q = io.nextInt(); IntQuadTree qt = new IntQuadTree(0, 1000, 0, 1000, null); f...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 8
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
fe55d30f1a759bc39c68a800ecd2f76c
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class CountingRectangles { private static final int START_TEST_CASE = 1; public static void solveCase(FastIO io, int testCase) { final int N = io.nextInt(); final int Q = io.nextInt(); IntQuadTree qt = new IntQuadTree(0, 1023, 0, 1023, null); f...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 8
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
dcefa4fc53eca82fdd7a9a7605aa0f47
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class CountingRectangles { private static final int START_TEST_CASE = 1; public static void solveCase(FastIO io, int testCase) { final int N = io.nextInt(); final int Q = io.nextInt(); QuadTree qt = new QuadTree(0, 1000, 0, 1000, null); for (in...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 8
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
f5c55b03f0c03a638bab39a132f60fe7
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class CountingRectangles { private static final int START_TEST_CASE = 1; public static void solveCase(FastIO io, int testCase) { final int N = io.nextInt(); final int Q = io.nextInt(); QuadTree qt = new QuadTree(0, 1000, 0, 1000, null); for (in...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 8
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
8e013206a5c8369c56f1e0c73155f52e
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); private static final int N = (int) (1e3 + 10); static int n, q; static long[][] a = new long[N][N]; static long[][] s = new long[N][N]; static String s1, s2, s3; public static void main(String[] a...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 8
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
f36f107457f6fccccd41c3f40fc32671
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int t = scn.nextInt(); while(t-- > 0){ int n = scn.nextInt(); int q = scn.nextInt(); long[][] dp1 = new long[1001][1001]; for(int i = 0; i <...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 8
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
8305014b2b1e76c8d05879d258bb755a
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int t = scn.nextInt(); while(t-- > 0){ int n = scn.nextInt(); int q = scn.nextInt(); long[][] dp1 = new long[1001][1001]; for(int i = 0; i <...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 8
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
eeb37329d89f001ad9d6c6e4356410fc
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.*; public class Solution { static MyScanner str = new MyScanner(); public static void main(String[] args) throws IOException { int T = i(); wh...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 8
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
33b639f3217fe8e7b189e03adcc83c73
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.util.*; import java.util.spi.CalendarDataProvider; import javax.imageio.metadata.IIOInvalidTreeException; import java.lang.*; import java.sql.Array; // import java.lang.invoke.ConstantBootstraps; // import java.math.BigInteger; // import java.beans.IndexedPropertyChangeEvent; import java.io.*; ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 8
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
6af6506e904efe6ae1c69116fa036452
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; public class p3 { BufferedReader br; StringTokenizer st; BufferedWriter bw; public static void main(String[] args)throws Exception { new p3().run(); } void run()throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); bw=new Bu...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 8
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
14218c45266e88710040e2d7021d2208
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class HarHarShambhu{ static Scanner in=new Scanner(); static long systemTime; static long mod = 1000000007; //static ArrayList<ArrayList<Integer>> adj; static int seive[]=new int[1000001]; sta...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 8
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
c4fe3acebd1fa6e1b9de8411187848e1
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
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.List; import java.util.StringTok...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 8
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
9801978ee699561aef3514639a730cbc
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class CodeForces { static FastScanner fs = new FastScanner(); static PrintWriter out=new PrintWriter(System.out); public static void main(String[]...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 8
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
6fee8e5070716072bef9a2b3bf4df9cf
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() ...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 8
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
28552b901985918567af6d43a1d1bcf8
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.StringTokenizer; public class Solution { static PrintWriter pw; static FastScanner s; pub...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 8
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
120ef74bf7c104fee4a9bb57fa02aff0
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { // static class MyScanner { BufferedReader br; StringTokenizer st; public MyScanner() { br = new BufferedReader(new InputStreamRe...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 8
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
3160f962e3d80f264d9250bd75a5bfba
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
//package codeforce.div4.r817; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Collections; import java....
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 8
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output
PASSED
5c429187a33668d7378e7691303bbb9c
train_109.jsonl
1661871000
You have $$$n$$$ rectangles, the $$$i$$$-th rectangle has height $$$h_i$$$ and width $$$w_i$$$.You are asked $$$q$$$ queries of the form $$$h_s \ w_s \ h_b \ w_b$$$. For each query output, the total area of rectangles you own that can fit a rectangle of height $$$h_s$$$ and width $$$w_s$$$ while also fitting in a recta...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.InputMismatchException; /** * * 二位前缀和 * */ public class E { public static void main(String[] args) { //Scanner sc = new Scanner(System.in); RealFastReader r = new RealFastReader(System.i...
Java
["3\n\n2 1\n\n2 3\n\n3 2\n\n1 1 3 4\n\n5 5\n\n1 1\n\n2 2\n\n3 3\n\n4 4\n\n5 5\n\n3 3 6 6\n\n2 1 4 5\n\n1 1 2 10\n\n1 1 100 100\n\n1 1 3 3\n\n3 1\n\n999 999\n\n999 999\n\n999 998\n\n1 1 1000 1000"]
6 seconds
["6\n41\n9\n0\n54\n4\n2993004"]
Note In the first test case, there is only one query. We need to find the sum of areas of all rectangles that can fit a $$$1 \times 1$$$ rectangle inside of it and fit into a $$$3 \times 4$$$ rectangle.Only the $$$2 \times 3$$$ rectangle works, because $$$1 &lt; 2$$$ (comparing heights) and $$$1 &lt; 3$$$ (comparing w...
Java 8
standard input
[ "brute force", "data structures", "dp", "implementation" ]
9e9c7434ebf0f19261012975fe9ee7d0
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case two integers $$$n, q$$$ ($$$1 \leq n \leq 10^5$$$; $$$1 \leq q \leq 10^5$$$) — the number of rectangles you own and the number of queries. Then $$$n$$$ lines follow, each contai...
1,600
For each test case, output $$$q$$$ lines, the $$$i$$$-th line containing the answer to the $$$i$$$-th query.
standard output