Candy Collection

Sort by

recency

|

13 Discussions

|

  • + 0 comments

    What is wrong in the following output (Do not consider extra informations printed)

    MIN COST = 1062

    Crate 0 --------- num.candy color

    • 196 36
    • 576 134
    • 687 146
    • 651 160
    • 777 181
    • 119 194
    • 776 202
    • 346 203
    • 838 221
    • 505 227
    • 181 238
    • 994 247
    • 753 261
    • 65 330
    • 89 348
    • 843 395
    • 753 432
    • 353 442
    • 466 454
    • 804 457
    • 721 499
    • 811 528
    • 265 555
    • 490 570
    • 179 575
    • 91 580
    • 342 585
    • 535 612
    • 343 619
    • 234 639
    • 684 642
    • 979 657
    • 311 660
    • 886 678
    • 422 686
    • 370 704
    • 306 752
    • 95 755
    • 537 756
    • 746 757
    • 802 777
    • 592 800
    • 342 813
    • 186 839
    • 493 847
    • 705 862
    • 430 893
    • 136 952
    • 621 971

    Crate 1 --------- num.candy color

    • 39 755

    The output for the accepted code is 1918.

    Input

    50

    528 660 755 585 247 202 134 146 395 555 893 813 227 194 261 847 639 575 704 619 36 777 432 756 181 862 971 686 442 457 499 330 757 657 580 678 612 203 752 238 642 348 839 570 755 800 221 160 454 952

    811 311 95 342 994 776 576 687 843 265 430 342 505 119 753 493 234 179 370 343 196 802 753 537 777 705 621 422 353 804 721 65 746 979 91 886 535 346 306 181 684 89 186 490 39 592 838 651 466 136

  • + 0 comments

    i didnt get the editorial , would anybody care to elaborate it ? :'(

  • + 0 comments

    int main() { int n,i,j,l=0,p=0,s=1,k=0; scanf("%d",&n); int a[n],b[n]; for(i=0;i

         l=l+b[i];
         printf("     %d",l);
     }
    printf("\n%d",l);
    
    return 0;
    

    } whats wrong

  • + 0 comments

    Can someone tell why are the example inputs separated as they are? Take the second one as example, why crate one has 3 elements (9 9 9) while crate two has 2 elements (2 2)? Take a similar example, but with candies = (9 9 9 10 2). Using the same separation of boxes like the example (which is what I dont understand), the result would be = (9 9 9) (10 2) = 9 + 10 = 19. However, since only the last color repeats, the logical separation of boxes for me would be (9 9 9 10) and (2), which is = 10 + 2 = 12.

    Am I missing something?

  • + 0 comments
    import sys
    from functools import reduce
    n = int(input().strip())
    T = list(map(int, input().strip().split(' ')))
    V = list(map(int, input().strip().split(' ')))
    # Write Your Code Here
    crates = {}
    cost = []
    for i in range(n):
        if T[i] not in crates.keys():
            crates[T[i]] = V[i]
        else:
            cost.append(reduce(lambda x, y: x | y, crates.values()))
            crates = {}
            crates[T[i]] = V[i]
    print(sum(cost))
    

    Shouldn't a crate have all unique Ti's? Why didn't this work? The question seemed simple at the first glance