SHARE
TWEET

Untitled

a guest Feb 21st, 2020 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <fstream>
  2.  
  3. using namespace std;
  4.  
  5. ifstream f("sumainsecv.in");
  6. ofstream g("sumainsecv.out");
  7.  
  8. int n,i,v[101],s,j;
  9.  
  10. int main()
  11. {
  12.     f>>n>>s;
  13.     for (i=1;i<=n;i++)
  14.     {
  15.         f>>v[i];
  16.         v[i]=v[i-1]+v[i];}
  17.     if (v[1]==s)
  18.     {g<<1<<" "<<1;
  19.     return 0;}
  20.     for (i=2;i<=n;i++)
  21.         for (j=1;j<i;j++)
  22.             if (v[i]-v[j]==s)
  23.             {g<<j+1<<" "<<i;
  24.             return 0;}
  25.     g<<0<<" "<<0;
  26.     return 0;
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top