925B - Resource Distribution - CodeForces Solution


binary search implementation sortings *1700

Please click on ads to support us..

Python Code:

def fin(c, x):
    return (x + c - 1) // c 

def ck(x, b):
    r = (n, n)
    for i in range(b, n):
        r = min(r, (i + fin(c[i][0], x), i))
    return r

def sol(r, l):
    if r[0] <= n and l[0] <= n and r[1] < n and l[1] < n :
        print("Yes")
        print(r[0] - r[1], l[0]- l[1])
        print(' '.join([str(x[1]) for x in c[r[1]:r[0]]]))
        print(' '.join([str(x[1]) for x in c[l[1]:l[0]]]))
        return True
    else:
        return False
    
n, x1, x2 = [int(x) for x in input().split()]
c = sorted([(int(x), i + 1) for i, x in enumerate(input().split())])

r1 = ck(x1, 0)
l1 = ck(x2, r1[0])
r2 = ck(x2, 0)
l2 = ck(x1, r2[0])

if not sol(r1, l1) and not sol(l2, r2):
    print("No")


Comments

Submit
0 Comments
More Questions

1684C - Column Swapping
57C - Array
1713D - Tournament Countdown
33A - What is for dinner
810A - Straight A
1433C - Dominant Piranha
633A - Ebony and Ivory
1196A - Three Piles of Candies
299A - Ksusha and Array
448B - Suffix Structures
1092B - Teams Forming
1166C - A Tale of Two Lands
544B - Sea and Islands
152B - Steps
1174D - Ehab and the Expected XOR Problem
1511A - Review Site
1316A - Grade Allocation
838A - Binary Blocks
1515D - Phoenix and Socks
1624D - Palindromes Coloring
1552F - Telepanting
1692G - 2Sort
1191A - Tokitsukaze and Enhancement
903A - Hungry Student Problem
52B - Right Triangles
1712A - Wonderful Permutation
1712D - Empty Graph
1712B - Woeful Permutation
1712C - Sort Zero
1028B - Unnatural Conditions