Desolation's blog

By Desolation, history, 10 years ago, In English

include

using namespace std;

typedef long long ll;

int main()

{

ll n,m,i,a[100010],no,sum;

cin>>n>>m;

for(i=1;i<=n;i++)
    {

    cin>>a[i];
    }

sum=m;

for(i=0;i<m;i++)
    {

    cin>>no;
            sum+=no;
    }

if(sum>n)
    {

    cout<<"-1";
            return 0;

}

for(i=sum;i<=n;i++)
    {
         if(a[i]!=0)
          {

       cout<<i;
                    return 0;
          }
}

cout<<"-1";

return 0;

}

Case: 7 2

0 0 0 0 0 1 2

  1 2

This Code's Output: 6

Correct Ans: 7

But this code still got AC.Why?

  • Vote: I like it
  • +3
  • Vote: I do not like it

»
10 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Many buggy solutions accepted for D but no one know why Codeforces doesn't rejudge it :(

»
10 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Friend of mine also got AC on buggy solution/