1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    vector<int> vec(200021, 0);
    int n;
    int i;
    cin >> n;
    while(n--)
    {
        cin >> i;
        int idx = i/32;
        i%=32;
        int b = 1;
        b<<=(i-1);
        if(!(vec[idx] & b))
        {
            vec[idx]^=b ;
            continue;
        }
        while(vec[idx] & b)
        {
            vec[idx]^=b ;
            b<<=1;
            if(b == 0)
            {
                ++idx;
                b=1;
            }
        }
        vec[idx]^=b;
    }
    auto it = vec.end();
    while(*(--it)==0);
    int j = 0;
    do
    {
        (*it)>>=1;
        ++j;
    } while(*it);
    cout << (distance(vec.begin(), it))*32+j << endl;;
    return 0;
}