Submission details
Task:Kyselyt
Sender:Metabolix
Submission time:2025-10-17 18:56:50 +0300
Language:C++ (C++20)
Status:READY
Result:30
Feedback
groupverdictscore
#1ACCEPTED10
#2ACCEPTED20
#30
#40
Test results
testverdicttimegroup
#1ACCEPTED0.00 s1, 2, 3, 4details
#2ACCEPTED0.00 s1, 2, 3, 4details
#3ACCEPTED0.00 s1, 3, 4details
#4ACCEPTED0.23 s2, 3, 4details
#5ACCEPTED0.27 s2, 3, 4details
#6ACCEPTED0.24 s2, 3, 4details
#70.04 s3, 4details
#8ACCEPTED0.46 s4details
#9ACCEPTED0.49 s4details
#100.07 s4details
#110.04 s3, 4details
#120.07 s4details
#130.04 s3, 4details
#140.07 s4details
#150.07 s4details
#16ACCEPTED0.45 s4details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:17:22: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         if (luvut[i] >= summataulu.size()) {

Code

#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    vector<int> luvut(n+1, -1);
    vector<vector<int>> summataulu(101);
    for (auto& rivi : summataulu) {
        rivi.resize(n+1, 0);
    }
    int max_luku = 0;
    for (int i = 1; i <= n; i++) {
        cin >> luvut[i];
        if (luvut[i] >= summataulu.size()) {
            return 0;
        }
        summataulu[luvut[i]][i] = 1;
        max_luku = max(max_luku, luvut[i]);
    }
    for (auto& rivi : summataulu) {
        for (int i = 1; i <= n; i++) {
            rivi[i] += rivi[i-1];
        }
    }

    for (int i = 0; i < q; i++) {
        int a, b;
        cin >> a >> b;
        int vastaus = -1;
        for (int luku = 1; luku <= max_luku; luku++) {
            int maara = summataulu[luku][b] - summataulu[luku][a-1];
            if (maara > (b - a + 1) / 2) {
                vastaus = luku;
            }
        }
        cout << vastaus << "\n";
    }
}

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: ACCEPTED

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
1
1
1
1
1
...

Test 5

Group: 2, 3, 4

Verdict: ACCEPTED

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
1
1
2
1
1
...

Test 6

Group: 2, 3, 4

Verdict: ACCEPTED

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
-1
-1
-1
-1
-1
...

Test 7

Group: 3, 4

Verdict:

input
100000 100000
141307 493258596 365539511 222...

correct output
-1
-1
-1
-1
-1
...

user output
(empty)

Test 8

Group: 4

Verdict: ACCEPTED

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
1
1
1
1
1
...

Test 9

Group: 4

Verdict: ACCEPTED

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
2
2
2
2
2
...

Test 10

Group: 4

Verdict:

input
200000 200000
286470749 280175209 741317063 ...

correct output
-1
-1
-1
-1
-1
...

user output
(empty)

Test 11

Group: 3, 4

Verdict:

input
100000 100000
613084013 1000000000 411999902...

correct output
-1
-1
-1
-1
1000000000
...

user output
(empty)

Test 12

Group: 4

Verdict:

input
200000 200000
613084013 1000000000 411999902...

correct output
1000000000
1000000000
-1
1000000000
-1
...

user output
(empty)

Test 13

Group: 3, 4

Verdict:

input
100000 100000
663307073 663307073 663307073 ...

correct output
329574367
965067805
768744535
691214891
21873594
...

user output
(empty)

Test 14

Group: 4

Verdict:

input
200000 200000
663307073 663307073 663307073 ...

correct output
107596959
249558965
679275202
760593154
725418770
...

user output
(empty)

Test 15

Group: 4

Verdict:

input
200000 200000
663307073 663307073 663307073 ...

correct output
211070558
49212342
651109313
264549124
651109313
...

user output
(empty)

Test 16

Group: 4

Verdict: ACCEPTED

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
1
2
1
1
1
...