Lisa's Workbook

Sort by

recency

|

12 Discussions

|

  • + 0 comments
    def workbook(n, k, arr):
        # Write your code here
        page=1
        sp=0
        for i in arr:
            for j in range(1,i+1):
                if j==page:
                    sp+=1
                if j%k==0 or j==i:
                    page+=1
        return sp
    
  • + 0 comments
    n,k = map(int,input().split(" "))
    x = k
    list1 = list(map(int,input().split(" ")))
    final_list1 = []
    for i in list1:
        l1 = [i for i in range(1,i+1)]
        l2 = []
        while len(l1) != 0:
            l2.append(l1[:x])
            l1 = l1[x:]
            x = min(k,len(l1))
        final_list1.extend(l2)
    final_list2 = [i for i in final_list1 if len(i) != 0]
    count = len([final_list2[i-1] for i in range(1,len(final_list2)+1) if i in final_list2[i-1]])
    print(count)``
    
  • + 0 comments

    int main() { int n,k,i,p=0,r=0; int t[n],s[i]; scanf("%d %d \n",&n,&k); for(i=0;i

     is this correct??
    
  • [deleted]
    + 0 comments

    Look in to case when maximum number of problems per page is 1

  • + 0 comments

    Finally passed test case 6 with this, although I'm still not sure why. Is there any way to get a look at the test cases?

    int main() { int chapters{0}, problemsPerPage{0}, problemsInChapter{0}, pageNumber{0}, specials{0};

    cin >> chapters >> problemsPerPage;
    
    while (cin >> problemsInChapter)
        for (int problemNumber{0};
             problemNumber < problemsInChapter;
             ++problemNumber)
        {
            if (problemNumber % problemsPerPage == 0)
                ++pageNumber;
            if (problemNumber + 1 == pageNumber)
                ++specials;
        }
    
    cout << specials;
    return 0;
    

    }