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 | 94e4ad88984ab39912c2e46a250902e6 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.Scanner;
public class xy_sequence
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int t =sc.nextInt();
while(t--!=0)
{
long c = 0;
int n= sc.nextInt();
int b = sc.nextInt();
int x = sc.nextInt();
int y = sc.nextInt();
long... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | f3666feb3e9bfe175b4cf08b972d43b8 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
public class Solution {
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 b = sc.nextInt();
int x = sc.nextInt();
int y = sc.nextInt();
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 6b585856cb4402830b12fd7940d3ec00 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.Scanner;
public class Main
{
static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) throws Exception
{
int tc = scanner.nextInt();
while (tc > 0)
{
int n = scanner.nextInt();
int limit = scanner.n... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 17f90143dac039fa3810606b832b2faa | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner in=new Scanner(System.in);
int t=in.nextInt();
while(t--!=0){
int n=in.nextInt(),B=in.nextInt(),x=in.nextInt(),y=in.nextInt();
long cur=0,res=0;
while(n-->0){
if(cur+x<... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 00a0e301ae22caecc13dc39e87050bf2 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.lang.*;
import java.util.*;
public class exam {
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0)
{
int n=sc.nextInt();
int B=sc.nextInt();
i... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 74d856e464e50f0ce9faa39fdeb5013e | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
import java.io.*;
public class Solution{
static class FastReader{
BufferedReader br;
StringTokenizer st;
public FastReader(){
br=new BufferedReader(new InputStreamReader(System.in));
}
String next(){
while(st==null || !st.hasMoreTo... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 3c094a96194950eca6433f39bc80d8e5 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes |
import java.util.Scanner;
public class Problem1657B {
public static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
int tc = scanner.nextInt();
while (tc-->0){
int n = scanner.nextInt();
int num = scanner.nextInt();
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 5dc94851ab977659f78c6920e6e6e48a | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
BigInteger B = new BigInteger(sc.next()), x = new B... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 14d49da911fe16c7feed007ab504de0c | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | //package com.company;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;
public class CodeforcesEducationalRounds_125_B {
@SuppressWarnings("FieldC... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | f1662fdaf9260b8c8cb9c81408ca0d2b | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
import java.math.*;
public class Solution{
public static final Scanner in= new Scanner(System.in);
public static long Solve(int n, Long B, Long x, Long y){
long array[] = new long[n+1];
array[0]=0;
for(int i=1; i<=n; i++){
if(array[i-1]+x<=B)
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 32349a7a469e864ce848eafc11b95fa0 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
import java.math.*;
public class Solution{
public static final Scanner in= new Scanner(System.in);
public static long Solve(int n, Long B, Long x, Long y){
long array[] = new long[n+1];
array[0]=0;
for(int i=1; i<=n; i++){
if(array[i-1]+x<=B)
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 23df45448f9c7d01f142e63f10b83f75 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
public class xysequence{
public static void main(String[] args) throws Exception{
Scanner scn=new Scanner(System.in);
int t=scn.nextInt();
while(t-->0){
int n=scn.nextInt();
int b=scn.nextInt();
int x=scn.nextInt();
int y=scn.nextInt();
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | e3bbbbed12a1b0e73dfd7a09a8a1b396 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes |
// Java is like Alzheimer's, it starts off slow, but eventually, your memory is gone.
import java.io.*;
import java.util.*;
public class Aqueous {
static MyScanner sc = new MyScanner();
static PrintWriter pw = new PrintWriter(System.out);
public static void main(String[] args) {
in... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 32417108abb2651a2123dce91ac62681 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.StringTokenizer;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.lang.reflect.Array;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
i... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | b1cf5fb043f108ffd4d82674f9d0c9f9 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
/**
* B_XY_Sequence
*/
public class B_XY_Sequence {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 402692638dfd25cba0e61a45fc590783 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.Scanner;
public class codeforces {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int t=in.nextInt();
for (int i=0; i<t; i++){
int n=in.nextInt();
int B=in.nextInt();
int x=in.nextInt();
in... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 29ae9591f086d85aaa683580fb27f933 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
public class Xyz
{
public static void main(String args[])
{
long n,B,a,b,t,i,s=0,j,m=0;
Scanner x=new Scanner(System.in);
t=x.nextInt();
while(t>0)
{
t--;
n=x.nextLong();
B=x.nextLong();
a=x.nextLong();
b=x.nextLong();
if(B>=a*n)
{
for(i=1;i<=n;i++)
{
s=s+a;
m=m+s;
}
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 5efca75e978abeabddaeb1a6d70afa3c | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
public class Main {
public static void main(String[] args) {
// write your code here
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for(int i=0;i<t;i++)
{
// HashMap<Integer,Integer> m=new HashMap<>();
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 791a544c7454dafd8e21b070734c7c3e | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.BigInteger;
public class B_XY_Sequence {
static Scanner t = new Scanner(System.in);
public static void kalingaisop() {
int n = t.nextInt();
Long B = t.nextLong();
Long x = t.nextLong();
Long ... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 6d43417c5aed513d521a359ee951ebb2 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.*;
public class Solution {
static long res(int n, int b, int x, int y){
long prev = 0;
long curr ;
long sum = 0;
for(int i = 0; i<n; i++){
if(prev + x <= b){
curr = prev + x;
}else{
curr = prev - y;
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 0a4fa6cb61fe7c6b9283ce45f4fac532 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
public class xyseqmar22 {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int t = scn.nextInt();
for(int i = 0 ; i < t ; i++){
int n = scn.nextInt();
int B = scn.nextInt();
int x = scn.nextInt();
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 51e7309fc13cb17c6102a7b418d3c9ec | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes |
import java.io.*;
import java.util.*;
public class C {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int b = sc.nextInt();
int x = ... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 5ae498aaaf00803cf099c6a84899acf1 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
import java.io.*;
public class Dd {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
while(T-->0){
int n = sc.nextInt();
int B =sc.nextInt();
int x = sc.nextInt();
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 74202cd8cfc6e114974d19d8170d3807 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.Scanner;
public class XYSequence {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
for (int t = sc.nextInt(); t > 0; t--) {
int n = sc.nextInt();
int B = sc.nextInt();
int x = sc.nextInt();
int y = sc.nextInt();
long sum = 0;
int next = 0;
for (... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 0a1a790652f1c3a2a48a02ed6c97b13b | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
public class tp {
static long max_sum(int n,long B,long x,long y)
{
long sum=0;
long a=0;
int i=0;
while(i<=n)
{
sum+=a;
i++;
if(a+x>B)
{
a=a-y;
}
else
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 3306b70eed76144f7da842865dca3595 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
import java.io.*;
public class a {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = ... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | d7c84a85df3fff8e44a947347d94cea0 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.ArrayList;
public class B {
static final FastReader sc = new FastReader();
static final PrintWriter ou... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 66983823f1debd7403cc1d60305eb73b | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
import java.util.Map.Entry;
import java.math.*;
public class Simple{
final static int MAX = 10000003;
static long mod = 998244353 ;
static int[] prime = new int[MAX];
public static long gcd(long a, long b) {
if (b == 0) return a;
return gcd(b, a%b);
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 48b3e6c5c64c90c816538d8e7ea227f4 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes |
import java.util.Scanner;
public class practice_359 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0){
int n = sc.nextInt();
int b = sc.nextInt();
int x = sc.nextInt();
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | fa93e07b48152bc4a5c76adeee633e7e | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.*;
import java.util.Arrays;
public class Sets {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
int numberSets = Integer.parseInt(br.readLine());
for (int nos = 0; nos <... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 76e66b030d3bdd7b4b5400c37b9af921 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.Scanner;
public class discrete {
public static void main(String[] args) {
Scanner input= new Scanner(System.in);
int t,n,B,x,y;
t=input.nextInt();
int ai=0;
long sum=0;
int aXi=0;
int aYi=0;
for(int i=0;i<t;i++) {
sum=0;
ai=0;
n=input.nextInt();
B=i... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | b7abc38544dfa47fc6c840b58c02bfca | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.Scanner;
public class code {
/* public static void print(int[] arr){
int n = arr.length;
for(int i = 0;i<n;i++){
System.out.print(arr[i]+" ");
}
}*/
public static void main(String args[]){
Scanner s = new Scanner(System.in);
int t... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 98afd816c7fef8424eb7512280bc739e | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.Scanner;
public class discrete {
public static void main(String[] args) {
Scanner input= new Scanner(System.in);
int t,n,B,x,y;
t=input.nextInt();
int ai=0;
long sum=0;
int aXi=0;
int aYi=0;
for(int i=0;i<t;i++) {
sum=0;
ai=0;
n=input.nextInt();
B=in... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 45fa19ec7be1c2914c462ed269fdb4a5 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
long n = sc.nextLong();
long B = sc.nextLong();
long x = sc.nextLong();
long y = sc.nextLong... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 3b54115c868f04697aebd99c9942e29d | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | //Code By KB.
import java.beans.Visibility;
import java.io.*;
import java.lang.annotation.Target;
import java.lang.reflect.Array;
import java.nio.channels.AsynchronousCloseException;
import java.security.KeyStore.Entry;
import java.util.*;
import java.util.logging.*;
import java.io.*;
import java.util.loggi... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 36701b24160c7fbc553314616e1dc570 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
long x,y,i,n,B,sum,j,prev;
double d;
for(i=0;i<t;i++){
n=sc.nextInt();
B=sc.nextInt();
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 014df9afef5697ae4da41adc9dddb1b4 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes |
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
// System.out.println(sc.nextByte());
xysequence(sc);
}
private static void xysequence(Scanner scanner){
int testcase=scanner.nextInt();
for(i... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 9ca6a9e55a9c6e0587f645dba6ee207d | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.Scanner;
import java.util.Arrays;
import java.util.HashSet;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Random;
public class Solution{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int test_cases = sc.nextInt();
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 5a27d4c9f9352dc30914d7e279fb58da | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes |
import java.util.*;
import java.io.*;
public class XYSequence {
public static void main(String[] args){
FastReader sc = new FastReader();
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int B = sc.nextInt();
int x = sc.nextInt(... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | d3898d19d439a78a6242348485b047ce | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | //Utilities
import java.io.*;
import java.util.*;
public class a {
static int t;
static int n, b, x, y;
static long[] a;
static long res;
public static void main(String[] args) throws IOException {
t = in.iscan();
while (t-- > 0) {
n = in.iscan(); b = in.iscan(); x = in.iscan(); y = in.iscan... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 7d0376fc9670f6fe4d94dfeae883e177 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
int n, B, x, y;
for(int j = 0; j < t; j++) {
n = in.nextInt();
B = in.nextInt();
x = in.n... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | d558cbd3080033a54a51d614c1e60322 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
public class Main {
static Scanner sc = new Scanner (System.in);
public static void main(String[] args) {
int test = sc.nextInt();
for ( int t=0; t<test; t++){
int n = sc.nextInt();
long B= sc.nextInt();
long x = sc.nextInt();
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | c664c599eec00bab4ae000b6925c816e | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.lang.*;
// import java.math.*;
import java.io.*;
import java.util.*;
public class Main{
public static int mod=(int)(1e9) + 7;
public static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
public static PrintWriter ot=new PrintWriter(System.out);
public static int[] ... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 62bbfa613c163654ca032f0d5eb2244f | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.security.cert.X509CRL;
import java.util.*;
import java.lang.*;
import java.util.stream.Collector;
import java.util.stream.Co... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | b4c992e84c1d3b45aeaa5c5802f0b8b2 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
public class XYSequence {
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0)
{
int n=sc.nextInt();
long B=sc.nextLong();
int x=sc.nextInt();
int y=sc.nextInt();
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 50af87ebe54e0bcf6e339404341cbe61 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import javax.swing.text.Segment;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import static java.lang.Math.*;
import java.util.*;
public class Main {
static public void main(String[] args){
out = new PrintWriter(new BufferedOutputStream(System.out));
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 796b9ff8ecc13232c3dd85430a0cd81c | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- != 0) {
long n = sc.nextLong();
long b = sc.nextLong();
long x = sc.nextLong();
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | e634ee470343b2b19f83b9f4deb4bcaf | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.Scanner;
public class XYSequence {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int j = 0; j < t; j++) {
int n = sc.nextInt();
long b= sc.nextLong();
long x= sc.next... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 5cc033df4cf19d89080333a63a3d66c9 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 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 Codechef {
public static void main (String[] args) throws java.lang.Exception {
Scanner scn = new Scanner(Sys... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 6c7d8a2c5f50651d90656cd55dcc5c60 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Arrays;
public class Main {
public static void main(String[] args) throws IOException {
FastScanner in = new FastScanner();
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | b823fae0c50867defc18f1c3d9b98c98 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
public class TaskB {
public static void main(String[] args) {
FastScanner in = new FastScanner();
PrintWriter out = new PrintWriter(S... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 7394ae8a49dd2c2b8de4b51d474f3c1a | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import java.util.stream.IntStream;
import java.util.stream.Stream;
public class Main {
public static void main(String[] args) {
in = new MyScanner();
out = new PrintWriter(new BufferedOutputStream(System.out));
try {
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | f50dc49d07377ff8548f9a3664573157 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.*;
import java.lang.Math;
import java.lang.reflect.Array;
import java.util.*;
import javax.swing.text.DefaultStyledDocument.ElementSpec;
public final class Solution {
static BufferedReader br = new BufferedReader(
new InputStreamReader(System.in)
);
static BufferedWriter bw = new B... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 3357622040833b856523c46b59bc4231 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Submit {
public static void main(String[] args) {
try (InputReader reader = new InputReader()) {
int t = reader.nextInt();
while (t-- > 0) {
int n = reade... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 71de719b49e5ff34339fe1ad05360819 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
public class a2 {
public static void main(String [] args) {
Scanner s=new Scanner(System.in);
int k=s.nextInt();
while(k-->0) {
int n=s.nextInt();
int b=s.nextInt();
int x=s.nextInt();
int y=s.nextInt();
long sum=0;
long f=0;
for(int i=0;i<n;i++) {
if(f+x... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 9bbb8ce2e093cecd527edb4a958b2e7f | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
import java.util.stream.*;
public class Sequence {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
StringBuilder result = new StringBuilder();
for(int i = 0; i < t; i++) {
int n = scan.nextInt();
long B = scan.nextLong... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 2f944243c05377910c8303debc4e3718 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | /*LoudSilence*/
import java.io.*;
import java.net.CookieHandler;
import java.util.*;
import static java.lang.Math.*;
public class Solution {
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 710d99db3b772b31dccd4d1d92d96bf4 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 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 Round12 {
public static void main(String[] args) {
FastReader fastRe... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 38c8bad864547f67ca80f5998a7eb7e0 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes |
import java.io.*;
import java.math.*;
import java.util.*;
public class P03 {
static class FastReader{
BufferedReader br ;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while(st==null || !st.hasMoreElements()){try ... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 64c05aa9741b6359f3175069ec8f5630 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class cf1657B {
public static void main(String[] args) {
FastReader sc = new FastReader();
int t = sc.nextInt();
while(t-->0) {
int n = sc.nextInt();... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 43ae3182470225ba6559039a612d9297 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.*;
import java.util.Arrays;
import java.util.InputMismatchException;
/**
* Provide prove of correctness before implementation. Implementation can cost a lot of time.
* Anti test that prove that it's wrong.
* <p>
* Do not confuse i j k g indexes, upTo and length. Do extra methods!!! Write mor... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 367b52adc3a9f7c43ccd1faf05495f89 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
public class C_1_E {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int t=input.nextInt();
for(int i=0;i<t;i++){
int n=input.nextInt(),B=input.nextInt(),x=input.nextInt(),y=input.nextInt();
long sum=0;
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | f70d6958da43926913ed938e79edf9af | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
public class Main {
static Kattio io;
static long mod = 998244353, inv2 = 499122177;
static {
io = new Kattio();
}
public static void main(String[] args) {
int t = io.nextInt();
for (int i = 0; i < t; i+... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 6a719b7f4fb1fbb9819ad919e3569ace | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static int mod = (int) (1e9 + 7);
static StringBuilder sb=new StringBuilder();
static void solve() {
int n=i();
int b=i();
int x=i();
long ans=0;
int y=i();
int[]arr=new int[n+1];
for(int i... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 9b876b2c82cc9b8c309af0bbe98641ff | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.awt.*;
import java.util.*;
public class Practice {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int b = sc.ne... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 3062ec53188682cd19dfda75ddeb7b82 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int t = Integer.parseInt(st.nextToken());
for (int j = 0; j <... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | d3e68a08f309310347f97b1dffe8465b | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.Scanner;
public class X {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
while (t-- > 0) {
int n = scanner.nextInt();
int B = scanner.nextInt();
int x = scanner.nextInt();
int y = scanner.nextInt();
long sum = 0;
int a = 0;
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 05a3ee3f75a65bb680a5feb96efaa8b0 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.*;
import java.math.*;
import java.security.KeyStore.Entry;
import java.util.*;
public class code {
private static boolean[] vis;
private static long[] dist;
private static long mod = 1000000000 + 7;
public static void merge(int arr[], int l, int m, int r)
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | cdfd490eb6a693f56e206a39c7ab9683 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.Arrays;
import java.util.Scanner;
import java.util.*;
public class A {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0) {
int n=sc.nextInt();
long B=sc.nextLong();
long x=sc.... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 1125f46c39c4db94cc85740fb45787a6 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes |
// Working program with FastReader
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class B1657 {
public static void main(String[] args) {
FastReader fs = new FastReader();
int t = fs.nextInt();
StringB... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 7b11bbcf144839b3d94d6c4ca205c13a | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class sol{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0)
{int n=sc.nextInt();
long b=sc.nextLong();
long x=sc.nextLong();
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 2ed341abcd8470b9972c077f6135e6ec | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Codeforces {
public static void main(String[] args) {
try {
FastScanner sc = new FastScanner();
int T = Integer.parseInt(sc.next());
wh... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | a874c45917e15269edad391cfcdde352 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes |
import java.io.*;
import java.util.*;
public class Solution{
public static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 88c207d1477d79a88f0b375a03b53677 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class E {
private static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | cb51306e598f0c9a08b8833f72de6a98 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
int i;
while(t-- > 0){
int n = sc.nextInt();
long b = sc.nextLong();
long x = sc.nextLong();
long y = sc.nextLong();
long a[] = n... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | e77001fa7d19ae598f8c8d0a33b7e65b | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
public class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
long n=sc.nextLong();
long b=sc.nextLong();
long x=sc.nextLong();
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 11 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 5c6734e03c61cc27ba83c559b5f527b6 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes |
import java.util.*;
public class cp1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t=sc.nextInt();
for (int tt = 0; tt < t; tt++) {
int n=sc.nextInt();
int b=sc.nextInt();
int x =sc.nextI... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 17 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 78ee4d03d151e4ded9339f01ac61343a | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;
import static java.lang.Math.*;
import static java.lang.System.*;
import static java.util.Arrays.*;
import static java.util.stream.IntStream.iterate;
public class Te... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 17 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 13e584244b4e9f4aa41ad923f6ecc89c | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.Scanner;
import java.util.Hash... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 17 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 842080218124ff6a0118c1053d309358 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
public class MyClass {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int tc = sc.nextInt();
while(tc-- > 0){
int n = sc.nextInt();
int b = sc.nextInt();
int x = sc.nextInt();
int y = sc.nextInt();
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 17 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | bccbabae982b61fcd059694be0000ff3 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes |
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class B {
public static void main(String[] args) throws java.lang.Exception {
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 8 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | e79c4db53089ad790fc93166b2889cb5 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
import java.util.Scanner;
import java.io.*;
import java.math.BigInteger;
public class Main{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int t;
t=sc.nextInt();
while(t-->0)
{
int n=sc.nextInt();
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 8 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 6b235331f1313d9622fff787caa7e6d9 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
while (t-- > 0) {
int n = in.nextInt();
int b = in.nextInt();
int x = in.nextInt();
int y = in.nextInt();
long sum = 0;
for (int i = 0, s ... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 8 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 0de92de45f65b953c80041f6668cdb79 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;
import java.util.Map;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader cin = new BufferedReader(new InputStr... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 8 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 6e48fa1e09eba487e36118f499d73018 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | //package hashcode;
import java.io.*;
//checkTriangle
import java.util.*;
//isSorted
//isPrime
//print
//sort
//input
public class G
{
static PrintWriter out = new PrintWriter(System.out);
static StringBuilder ans=new StringBuilder();
static FastReader in=new FastReader();
public static... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 8 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 3f04e98e7a4641e7c9fca5af6b4c4438 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main{
private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static String readln() throws IOException{
String line = br.readLine();
return line;
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 8 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 8a07927aafabe97070c642fdb05b5735 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreEle... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 8 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | f7ca8b78817df56f47aebab8a670f40e | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
public class sksss {
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
sksss ob=new sksss();
int t=sc.nextInt();
for(int i=0;i<t;i++)
{
long n=sc.nextLong();
long B=sc.nextLong();
lo... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 8 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 9d9c0dc9b4d89db435098e14ae0fe269 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
public class handling {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scn=new Scanner(System.in);
int t=scn.nextInt();
while(t>0) {
int n=scn.nextInt();
long b=scn.nextLong();
long x=scn.nextLong();
long y=scn.nextLong();
long ... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 8 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 05cd1f1e838ee7e5af28df44efa090f5 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Random;
import java.util.StringTokenizer;
public class EduB {
static FastScanne... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 8 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | dcc9d6b2402fe8293d98a60c953eb2c3 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.Scanner;
public class codeforces2 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for (int j = 0; j < t; j++) {
long n=sc.nextLong();
long B=sc.nextLong();
long x... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 8 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 3a905278bdc0d71b24aa2309451b1716 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.*;
public class Main {
public static void main(String ar[]) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int b = sc.nextInt();
int x = sc.nextInt();
int y = sc.... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 8 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 68e445153b77b817ecdc66c7cc7a1f67 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | //package codeforces;
import java.util.*;
import java.io.*;
public class Solution {
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 B= sc.nextInt();
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 8 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 93acbddeb0ccf49191737dcd18113af6 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.lang.*;
import java.io.*;
import java.util.*;
public class My
{
public static void main(String[] args)
{
Scanner scn=new Scanner(System.in);
int t=scn.nextInt();
while(t-->0)
{
long sum=0;
long n=scn.nextLong();
long b=... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 8 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | e8704e7cbdc9de9e52879447b413a15b | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.util.Scanner;
import java.util.StringTokenizer;
public class ThirdAttemptPORCODIO {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
StringTokenizer st;
int t = Integer.parseInt(scan.nextLine());
int n;
long b, x, y, prev;
long[] result = new long[t... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 8 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | b45c36ef89cd3321a459d07eb8d2dfdf | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
public class Main {
///
// Two theorams are used to find ncrp
// Lucas theoram and the fermit theoram
// a^p-1=1(modp) exam... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 8 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | f194dd0afd700d67820c09d0488917ec | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
public class Main {
///
// Two theorams are used to find ncrp
// Lucas theoram and the fermit theoram
// a^p-1=1(modp) ex... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 8 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | efde998a0ecefd9cbddba5acb6e351dc | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
// static boolean[] prime = new boolean[10000000];
final static long mod = 998244353;
public static void main(String[] args) {
// sieve();
InputReader in = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out);
... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 8 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | 6d0c5d8d66862ce36604f164348bec90 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | /*package whatever //do not write package name here */
import java.util.*;
public class GFG {
public static void main (String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int o=0;o<t;o++){
int n=sc.nextInt();
int b=sc.nextInt();
int x=sc.nextInt();
in... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 8 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output | |
PASSED | bdf513a3f6bc9c7457369c3797fab9a9 | train_110.jsonl | 1647960300 | You are given four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$. You should build a sequence $$$a_0, a_1, a_2, \dots, a_n$$$ where $$$a_0 = 0$$$ and for each $$$i \ge 1$$$ you can choose: either $$$a_i = a_{i - 1} + x$$$ or $$$a_i = a_{i - 1} - y$$$. Your goal is to build such a sequence $$$a$$$ that $$$a_i \le B$... | 256 megabytes | import java.io.*;
import java.lang.*;
import java.util.*;
public class solution {
public static void main (String[] args){
int t=sc.nextInt();
while(t--!=0) {
int n=sc.nextInt();long b=sc.nextLong();long x=sc.nextLong();long y=sc.nextLong();
long a[]=new long[n+1];long sum=0;
for(int i=1;... | Java | ["3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3"] | 2 seconds | ["15\n4000000000\n-10"] | NoteIn the first test case, the optimal sequence $$$a$$$ is $$$[0, 1, 2, 3, 4, 5]$$$.In the second test case, the optimal sequence $$$a$$$ is $$$[0, 10^9, 0, 10^9, 0, 10^9, 0, 10^9]$$$.In the third test case, the optimal sequence $$$a$$$ is $$$[0, -3, -6, 1, -2]$$$. | Java 8 | standard input | [
"greedy"
] | 2c921093abf2c5963f5f0e96cd430456 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains four integers $$$n$$$, $$$B$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le B, x, y \le 10^9$$$). It's guaranteed that the... | 800 | For each test case, print one integer — the maximum possible $$$\sum\limits_{i=0}^{n}{a_i}$$$. | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.