Submission details
Task:Kyselyt
Sender:ollpu
Submission time:2025-10-19 23:20:23 +0300
Language:C++ (C++20)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
#40
Test results
testverdicttimegroup
#1ACCEPTED0.00 s1, 2, 3, 4details
#2ACCEPTED0.00 s1, 2, 3, 4details
#30.00 s1, 3, 4details
#4ACCEPTED0.17 s2, 3, 4details
#50.19 s2, 3, 4details
#60.18 s2, 3, 4details
#70.19 s3, 4details
#8ACCEPTED0.37 s4details
#90.41 s4details
#100.41 s4details
#110.20 s3, 4details
#120.42 s4details
#130.19 s3, 4details
#140.39 s4details
#150.40 s4details
#160.32 s4details

Code

#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    int x[n], y[n];
    for (int i = 0; i < n; ++i) cin >> x[i];
    pair<int, int> m[n];
    for (int i = 0; i < n; ++i) {
        m[i] = {x[i], i};
    }
    sort(m, m+n);
    int ls = 0, ny = 0;
    for (auto [v, i] : m) {
        if (v != ls) ny++;
        y[i] = ny;
        ls = v;
    }
    const int K = 24;
    int l[q], g[q][K];
    int cnt[q][K] {};
    vector<pair<int, int>> ev[n];
    for (int i = 0; i < q; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        l[i] = b-a+1;
        if (a) ev[a-1].push_back({i, -1});
        ev[b].push_back({i, 1});
        for (int j = 0; j < K; ++j) {
            g[i][j] = y[a+rand()%(b-a+1)];
        }
    }
    int z[n] {};
    for (int i = 0; i < n; ++i) {
        z[y[i]]++;
        for (auto [qi, c] : ev[i]) {
            for (int j = 0; j < K; ++j) {
                cnt[qi][j] += c * z[g[qi][j]];
            }
        }
    }
    for (int i = 0; i < q; ++i) {
        int res = -1;
        for (int j = 0; j < K; ++j) {
            if (cnt[i][j] > l[i]/2) res = x[g[i][j]];
        }
        cout << res << "\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:

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:

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

Test 6

Group: 2, 3, 4

Verdict:

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

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:

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

Test 11

Group: 3, 4

Verdict:

input
100000 100000
613084013 1000000000 411999902...

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

user output
-1
-1
-1
-1
880359054
...

Test 12

Group: 4

Verdict:

input
200000 200000
613084013 1000000000 411999902...

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

user output
139179906
139179906
-1
139179906
-1
...

Test 13

Group: 3, 4

Verdict:

input
100000 100000
663307073 663307073 663307073 ...

correct output
329574367
965067805
768744535
691214891
21873594
...

user output
762227828
832364259
785866095
628984381
663307073
...

Test 14

Group: 4

Verdict:

input
200000 200000
663307073 663307073 663307073 ...

correct output
107596959
249558965
679275202
760593154
725418770
...

user output
572589546
392826688
681690682
386381016
847840320
...

Test 15

Group: 4

Verdict:

input
200000 200000
663307073 663307073 663307073 ...

correct output
211070558
49212342
651109313
264549124
651109313
...

user output
663307073
663307073
663307073
663307073
663307073
...

Test 16

Group: 4

Verdict:

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