Question in 377D Div2 Exams

Revision en1, by rohansumant, 2016-10-30 00:24:58

Consider the following test case

10 3
0 3 0 1 0 0 0 0 2 0
1 1 4

The following AC submission gives the answer as 9. I would like to know how is the answer 9 correct. Since subject 3 requires 4 days of preparation, which clearly isn't possible, shouldn't the answer be -1 ?

#include<bits/stdc++.h>  
using namespace std;  
int main()  
{  
int n,m;  
cin>>n>>m;  
int arr[n+1];  
for(int i=1;i<=n;i++)cin>>arr[i];  
int sum=m,x;  
for(int i=0;i<m;i++){cin>>x; sum+=x;}  
  
for(int i=sum;i<=n;i++)if(arr[i]){cout<<i; return 0;}  
cout<<-1;  
}

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English rohansumant 2016-10-30 00:24:58 628 Initial revision (published)