CSES - Siperia opettaa 5.0 - Results
Submission details
Task:Hacker Cups and Balls
Sender:JesseNiininen
Submission time:2017-03-09 13:24:13 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.04 sdetails
#2ACCEPTED0.03 sdetails
#3ACCEPTED0.02 sdetails
#4ACCEPTED0.03 sdetails
#5ACCEPTED0.04 sdetails
#6ACCEPTED0.06 sdetails
#7ACCEPTED0.04 sdetails
#8ACCEPTED0.03 sdetails
#9ACCEPTED0.05 sdetails
#10ACCEPTED0.04 sdetails
#11ACCEPTED0.05 sdetails
#12ACCEPTED0.06 sdetails
#13ACCEPTED0.88 sdetails
#14--details
#15--details
#16--details
#17--details
#18--details
#19--details
#20--details
#21--details
#22ACCEPTED0.21 sdetails
#23--details
#24--details
#25ACCEPTED0.12 sdetails
#26ACCEPTED0.12 sdetails

Code

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;

    vector<int> v(n);
    for(int i = 0; i < n; i++){
        int num;
        cin >> num;
        v[i] = num;
    }

    vector<pair<int, int>> c(m);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        c[i] = {a, b};
    }
    int skipTo = 0;
    for(int i = m - 1; i >= 0; i--){
        int a = c[i].first;
        int b = c[i].second;
        if((a == 0 && b == n - 1) || (a == n - 1 && b == 0)){
            skipTo = i;
            break;
        }
    }

    for(int i = skipTo; i < m; i++){
        int a = c[i].first;
        int b = c[i].second;
        if(a > b){
            sort(v.begin() + b, v.begin() + a + 1);
            reverse(v.begin() + b, v.begin() + a + 1);
        }else{
            sort(v.begin() + a, v.begin() + b + 1);
        }
    }

    cout << v[n / 2];
}

Test details

Test 1

Verdict: ACCEPTED

input
3 2
1 3 2
1 3
3 1

correct output
2

user output
2

Test 2

Verdict: ACCEPTED

input
5 2
5 1 4 2 3
1 4
5 2

correct output
4

user output
4

Test 3

Verdict: ACCEPTED

input
1 0
1

correct output
1

user output
1

Test 4

Verdict: ACCEPTED

input
1 1
1
1 1

correct output
1

user output
1

Test 5

Verdict: ACCEPTED

input
1 10
1
1 1
1 1
1 1
...

correct output
1

user output
1

Test 6

Verdict: ACCEPTED

input
3 10
2 3 1
1 1
2 3
2 3
...

correct output
2

user output
2

Test 7

Verdict: ACCEPTED

input
5 10
3 2 4 5 1
5 3
2 1
2 1
...

correct output
4

user output
4

Test 8

Verdict: ACCEPTED

input
7 10
1 5 3 6 4 2 7
3 1
4 5
7 2
...

correct output
3

user output
3

Test 9

Verdict: ACCEPTED

input
9 10
5 3 9 8 2 4 1 7 6
3 6
2 2
3 1
...

correct output
2

user output
2

Test 10

Verdict: ACCEPTED

input
9 10
4 6 8 3 1 2 5 7 9
5 9
9 3
1 7
...

correct output
5

user output
5

Test 11

Verdict: ACCEPTED

input
99 100
33 54 86 85 32 70 47 59 98 81 ...

correct output
50

user output
50

Test 12

Verdict: ACCEPTED

input
999 1000
403 659 941 361 902 420 562 40...

correct output
461

user output
461

Test 13

Verdict: ACCEPTED

input
9999 10000
8825 6550 9856 4921 5469 7019 ...

correct output
3680

user output
3680

Test 14

Verdict:

input
51415 50216
42355 19584 12430 4886 21835 1...

correct output
42640

user output
(empty)

Test 15

Verdict:

input
99999 100000
86561 69211 10709 40653 63761 ...

correct output
49166

user output
(empty)

Test 16

Verdict:

input
99999 100000
50393 94271 27420 69389 62906 ...

correct output
37388

user output
(empty)

Test 17

Verdict:

input
99999 100000
55963 34569 33638 11733 14583 ...

correct output
66896

user output
(empty)

Test 18

Verdict:

input
99999 100000
23085 10457 5546 1569 42452 10...

correct output
71234

user output
(empty)

Test 19

Verdict:

input
99999 100000
90828 34481 10990 74758 89452 ...

correct output
85498

user output
(empty)

Test 20

Verdict:

input
99999 100000
72770 96635 93330 99517 50465 ...

correct output
1

user output
(empty)

Test 21

Verdict:

input
99999 100000
50747 54311 37637 60185 52083 ...

correct output
99999

user output
(empty)

Test 22

Verdict: ACCEPTED

input
99999 100000
74605 62077 35821 90758 88963 ...

correct output
39458

user output
39458

Test 23

Verdict:

input
99999 100000
41714 10593 31139 16591 60872 ...

correct output
50002

user output
(empty)

Test 24

Verdict:

input
99999 99998
34921 96615 61384 91011 31201 ...

correct output
20597

user output
(empty)

Test 25

Verdict: ACCEPTED

input
99999 100000
72111 4249 26146 40294 35803 2...

correct output
50000

user output
50000

Test 26

Verdict: ACCEPTED

input
99999 100000
28991 50696 14403 60081 49795 ...

correct output
50000

user output
50000