Неправильный вывод, если все случаи вводятся вместе, и правильный, если рассматривать их по отдельности. ⇐ JAVA
Неправильный вывод, если все случаи вводятся вместе, и правильный, если рассматривать их по отдельности.
I was trying Codeforces problem 1921-C. Problem is when I put a single test case it works fine but with if I put all the test cases together the result changes.
For the test case
12 621526648 2585904 3566299 51789 61859 71998 73401 247675 298086 606959 663464 735972 806043 806459 919683 the ouput should be "Yes" but when multiple inputs including this are given together it shows "No".
My code is
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int test = sc.nextInt(); for (int t_ = 0; t_ < test; t_++) { long n = sc.nextLong(); long f = sc.nextLong(); long a = sc.nextLong(); long b = sc.nextLong(); long now = 0L; for (int i = 0; i < n; i++){ long m = sc.nextLong(); long min = Math.min(a*(m - now), b); f = f - min; if(f 0) { System.out.println("Yes"); } } } }
Источник: https://stackoverflow.com/questions/780 ... ndividuall
I was trying Codeforces problem 1921-C. Problem is when I put a single test case it works fine but with if I put all the test cases together the result changes.
For the test case
12 621526648 2585904 3566299 51789 61859 71998 73401 247675 298086 606959 663464 735972 806043 806459 919683 the ouput should be "Yes" but when multiple inputs including this are given together it shows "No".
My code is
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int test = sc.nextInt(); for (int t_ = 0; t_ < test; t_++) { long n = sc.nextLong(); long f = sc.nextLong(); long a = sc.nextLong(); long b = sc.nextLong(); long now = 0L; for (int i = 0; i < n; i++){ long m = sc.nextLong(); long min = Math.min(a*(m - now), b); f = f - min; if(f 0) { System.out.println("Yes"); } } } }
Источник: https://stackoverflow.com/questions/780 ... ndividuall
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Как мне добавить новые строки с моими данными, поскольку они не вводятся [дубликат]
Anonymous » » в форуме JAVA - 0 Ответы
- 26 Просмотры
-
Последнее сообщение Anonymous
-