Codeforces 474B. Worms solution

 Solution in C++:

 ///La ilaha illellahu muhammadur rasulullah

///******Bismillahir-Rahmanir-Rahim******///

///Abul Hasnat  Tonmoy

///Department of CSE,23rd batch

    ///Islamic University,Bangladesh

    1. #include <bits/stdc++.h>
    2. using namespace std;
    3. int main()
    4. {
    5. int n,m,i,l,v;
    6. cin>>n;
    7. int a[n+9];
    8. cin>>a[0];
    9. for(i=1; i<n; i++)
    10. {
    11. cin>>a[i];
    12. a[i]+=a[i-1];
    13. }
    14. cin>>m;
    15. for(i=0; i<m; i++)
    16. {
    17. cin>>v;
    18. l=lower_bound(a,a+n,v)-a;
    19. cout<<l+1<<endl;
    20. }
    21. }

    No comments

    Most View Post

    Recent post

    RESTful APIs with CRUD Operations in Laravel 12| (2025)

      RESTful APIs serve as the foundation of modern web development. They follow a set of rules called Representational State Transfer (REST) t...

    Powered by Blogger.