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

    Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

        Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

    Powered by Blogger.