답안 #147581

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
147581 2019-08-30T07:27:15 Z KCSC Turnir (COCI17_turnir) C++14
100 / 100
819 ms 25900 KB
#include <bits/stdc++.h>
using namespace std;

const int DIM = (1 << 20) + 5;

int pwr[DIM], sol[DIM];
pair<int, int> arr[DIM];

int main(void) {
    int n;
    cin >> n;
    n = (1 << n);
    for (int i = 1; i <= n; ++i) {
        cin >> arr[i].first;
        arr[i].second = i;
    }
    sort(arr + 1, arr + n + 1);
    for (int i = 2; i <= n; ++i)
        pwr[i] = pwr[i >> 1] + 1;
    for (int i = 1, j = 1; i <= n; ++i) {
        while (j + 1 <= n && arr[j + 1].first <= arr[i].first)
            ++j;
        sol[arr[i].second] = pwr[n] - pwr[j];
    }
    for (int i = 1; i <= n; ++i)
        cout << sol[i] << " ";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 6 ms 504 KB Output is correct
5 Correct 23 ms 1016 KB Output is correct
6 Correct 48 ms 1912 KB Output is correct
7 Correct 94 ms 3448 KB Output is correct
8 Correct 174 ms 6352 KB Output is correct
9 Correct 406 ms 13376 KB Output is correct
10 Correct 819 ms 25900 KB Output is correct