Task: | Kyselyt |
Sender: | TapaniS |
Submission time: | 2025-10-19 22:20:03 +0300 |
Language: | Java |
Status: | READY |
Result: | 10 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 10 |
#2 | TIME LIMIT EXCEEDED | 0 |
#3 | TIME LIMIT EXCEEDED | 0 |
#4 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.09 s | 1, 2, 3, 4 | details |
#2 | ACCEPTED | 0.08 s | 1, 2, 3, 4 | details |
#3 | ACCEPTED | 0.08 s | 1, 3, 4 | details |
#4 | TIME LIMIT EXCEEDED | -- | 2, 3, 4 | details |
#5 | TIME LIMIT EXCEEDED | -- | 2, 3, 4 | details |
#6 | TIME LIMIT EXCEEDED | -- | 2, 3, 4 | details |
#7 | RUNTIME ERROR | 0.41 s | 3, 4 | details |
#8 | TIME LIMIT EXCEEDED | -- | 4 | details |
#9 | TIME LIMIT EXCEEDED | -- | 4 | details |
#10 | RUNTIME ERROR | 0.70 s | 4 | details |
#11 | RUNTIME ERROR | 0.56 s | 3, 4 | details |
#12 | RUNTIME ERROR | 0.80 s | 4 | details |
#13 | RUNTIME ERROR | 0.40 s | 3, 4 | details |
#14 | RUNTIME ERROR | 0.63 s | 4 | details |
#15 | RUNTIME ERROR | 0.76 s | 4 | details |
#16 | TIME LIMIT EXCEEDED | -- | 4 | details |
Code
import java.util.*; import java.io.*; public class kyselyt2 { public static void main(String[] args) throws IOException { // Scanner input = new Scanner(System.in); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); // String kokomaara = input.nextLine(); String[] parts = br.readLine().split(" "); // String[] kokomaaraParts = kokomaara.split("\\s+"); int n = Integer.parseInt(parts[0]); int q = Integer.parseInt(parts[1]); // int t = Integer.parseInt(input.nextLine()); int[] x = new int[n]; // luvut int[] a = new int[q]; // alku int[] b = new int[q]; // loppu String[] parts2 = br.readLine().split(" "); // String num = input.nextLine(); // String[] numParts = num.split("\\s+"); for (int i = 0; i < n; i++) { x[i] = Integer.parseInt(parts2[i]); } // String[] rajat = new String[q]; // numerot for (int i = 0; i < q; i++) { String[] parts3 = br.readLine().split(" "); // rajat[i] = input.nextLine(); // String[] rajaParts = rajat[i].split("\\s+"); a[i] = Integer.parseInt(parts3[0]); b[i] = Integer.parseInt(parts3[1]); } // input.close(); // Program here StringBuilder sb = new StringBuilder(); for (int i = 0; i < q; i++) { // tapaus q int ans = -1; int pit = b[i] - a[i] + 1; float suhde = 0.0f; int[] counts = new int[101]; // Map<Integer, Integer> counts = new HashMap<>(); for (int i2 = (a[i]-1); i2 <= (b[i]-1); i2++) { // counts.put(x[i2], counts.getOrDefault(x[i2], 0) + 1); counts[x[i2]]++; } int mostCommon = 0; int highestCount = 0; /* for (Map.Entry<Integer, Integer> entry : counts.entrySet()) { if (entry.getValue() > highestCount) { highestCount = entry.getValue(); mostCommon = entry.getKey(); } } */ for (int i3 = 1; i3 <= 100; i3++) { if (counts[i3] > highestCount) { highestCount = counts[i3]; mostCommon = i3; } } suhde = (float)highestCount / pit; if (suhde > 0.5) { ans = mostCommon; } sb.append(ans).append('\n'); } // tapaus q // tulostus // System.out.println(dy + " " + dx); System.out.print(sb.toString()); } }
Test details
Test 1
Group: 1, 2, 3, 4
Verdict: ACCEPTED
input |
---|
100 100 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
correct output |
---|
1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 ... |
Test 2
Group: 1, 2, 3, 4
Verdict: ACCEPTED
input |
---|
100 100 2 1 2 2 1 2 2 2 1 2 2 1 1 1 1 ... |
correct output |
---|
2 1 1 2 1 ... |
user output |
---|
2 1 1 2 1 ... |
Test 3
Group: 1, 3, 4
Verdict: ACCEPTED
input |
---|
100 100 5 19 44 88 14 79 50 44 14 99 7... |
correct output |
---|
-1 -1 -1 -1 -1 ... |
user output |
---|
-1 -1 -1 -1 -1 ... |
Test 4
Group: 2, 3, 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 100000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
correct output |
---|
1 1 1 1 1 ... |
user output |
---|
(empty) |
Test 5
Group: 2, 3, 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 100000 1 1 1 2 1 2 1 1 2 1 1 1 1 2 2 ... |
correct output |
---|
1 1 2 1 1 ... |
user output |
---|
(empty) |
Test 6
Group: 2, 3, 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 100000 8 2 6 1 10 4 9 7 8 10 4 2 8 2 ... |
correct output |
---|
-1 -1 -1 -1 -1 ... |
user output |
---|
(empty) |
Test 7
Group: 3, 4
Verdict: RUNTIME ERROR
input |
---|
100000 100000 141307 493258596 365539511 222... |
correct output |
---|
-1 -1 -1 -1 -1 ... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 110738261 out of bounds for length 101 at kyselyt2.main(kyselyt2.java:66)
Test 8
Group: 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 200000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
correct output |
---|
1 1 1 1 1 ... |
user output |
---|
(empty) |
Test 9
Group: 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 200000 1 2 2 2 1 2 2 1 1 1 1 1 1 1 1 ... |
correct output |
---|
2 2 2 2 2 ... |
user output |
---|
(empty) |
Test 10
Group: 4
Verdict: RUNTIME ERROR
input |
---|
200000 200000 286470749 280175209 741317063 ... |
correct output |
---|
-1 -1 -1 -1 -1 ... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 633065655 out of bounds for length 101 at kyselyt2.main(kyselyt2.java:66)
Test 11
Group: 3, 4
Verdict: RUNTIME ERROR
input |
---|
100000 100000 613084013 1000000000 411999902... |
correct output |
---|
-1 -1 -1 -1 1000000000 ... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 714932756 out of bounds for length 101 at kyselyt2.main(kyselyt2.java:66)
Test 12
Group: 4
Verdict: RUNTIME ERROR
input |
---|
200000 200000 613084013 1000000000 411999902... |
correct output |
---|
1000000000 1000000000 -1 1000000000 -1 ... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 1000000000 out of bounds for length 101 at kyselyt2.main(kyselyt2.java:66)
Test 13
Group: 3, 4
Verdict: RUNTIME ERROR
input |
---|
100000 100000 663307073 663307073 663307073 ... |
correct output |
---|
329574367 965067805 768744535 691214891 21873594 ... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 329574367 out of bounds for length 101 at kyselyt2.main(kyselyt2.java:66)
Test 14
Group: 4
Verdict: RUNTIME ERROR
input |
---|
200000 200000 663307073 663307073 663307073 ... |
correct output |
---|
107596959 249558965 679275202 760593154 725418770 ... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 977467597 out of bounds for length 101 at kyselyt2.main(kyselyt2.java:66)
Test 15
Group: 4
Verdict: RUNTIME ERROR
input |
---|
200000 200000 663307073 663307073 663307073 ... |
correct output |
---|
211070558 49212342 651109313 264549124 651109313 ... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 211070558 out of bounds for length 101 at kyselyt2.main(kyselyt2.java:66)
Test 16
Group: 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 200000 2 2 2 1 2 1 1 2 2 1 1 1 1 2 1 ... |
correct output |
---|
1 2 1 1 1 ... |
user output |
---|
(empty) |