Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int a[105],n,S;
- int main()
- {
- cin>>n>>S;
- for(int i=1;i<=n;i++)
- cin>>a[i];
- for(int i=1;i<=n;i++)
- for(int j=i;j<=n;j++)
- {
- int s=0;
- for(int pas=i;pas<=j;pas++)
- s+=a[pas];
- if(s==S)
- {
- cout<<i<<" "<<j<<"\n";
- return 0;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment