tanasaradu

Untitled

Dec 5th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int a[105],n,S;
  4. int main()
  5. {
  6. cin>>n>>S;
  7. for(int i=1;i<=n;i++)
  8. cin>>a[i];
  9. for(int i=1;i<=n;i++)
  10. for(int j=i;j<=n;j++)
  11. {
  12. int s=0;
  13. for(int pas=i;pas<=j;pas++)
  14. s+=a[pas];
  15. if(s==S)
  16. {
  17. cout<<i<<" "<<j<<"\n";
  18. return 0;
  19. }
  20. }
  21. return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment