cp-library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub kobejean/cp-library

:heavy_check_mark: cp_library/alg/iter/argsort_bounded_fn.py

Verified with

Code

import cp_library.alg.iter.__header__

def argsort_bounded(A, mx):
    I, cnt, t = [0]*len(A), [0]*(mx+1), 0
    for a in A: cnt[a] += 1
    for i in range(mx+1): cnt[i], t = t, t+cnt[i]
    for i,a in enumerate(A): I[cnt[a]] = i; cnt[a] += 1
    return I
'''
╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸
             https://kobejean.github.io/cp-library               
'''

def argsort_bounded(A, mx):
    I, cnt, t = [0]*len(A), [0]*(mx+1), 0
    for a in A: cnt[a] += 1
    for i in range(mx+1): cnt[i], t = t, t+cnt[i]
    for i,a in enumerate(A): I[cnt[a]] = i; cnt[a] += 1
    return I
Back to top page