ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1247. Check a Sequence

Why access violation?
Posted by Leonid Chistov 18 Apr 2003 22:31
#include <iostream.h>

int main()
{
 long S,N,Sum;
 bool X;
 int A[30000];
 cin>>S;cin>>N;
 Sum=0;X=1;
 for(long i=1;i<=S;i++)cin>>A[i];
 for(long i=S;i>=1;i--)
 {
  Sum+=A[i];
  if(Sum>S-i+1+N)X=0;
 }
 if(X==0) cout<<"NO"; else cout<<"YES";
         return 0;
}
Re: Why access violation?
Posted by Dilyan 23 Jul 2004 04:20
it has to ba int A[30001] not int A[30000]

just try it

Edited by author 23.07.2004 04:20

Edited by author 23.07.2004 04:20