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 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

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

    Powered by Blogger.