Sorting Stress Test


Submit solution

Points: 100
Time limit: 5.0s
Memory limit: 1G

Author:
Problem type
Allowed languages
C, C++

The following program passes all tests:

#include<algorithm>
#include<iostream>
const int SIZE = 20000000;
uint64_t a[SIZE];
int main() {
    int n;
    std::cin >> a[0] >> n;
    for(int i = 1; i < n; i++) {
        uint64_t x = a[i - 1];
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        a[i] = x;
    }
    std::sort(a, a + n);
    std::cout << a[n / 2] << std::endl;
    return 0;
}

Input

The input consists of a single line containing two positive integers \(a[0]\) and \(n\). The value \(a[0]\) fits in an unsigned 64-bit integer, and \(1 \le n \le 2 \times 10^7\).

Output

Output a single line containing the answer.

Sample Input 1

1969464034641677472 5

Sample Output 1

13532146017095035750