Hello Codeforces,
Whenever I click on any user profile, I see that that user has quite a bunch of friends. How do you guys know each other? How do you make friends?
# | User | Rating |
---|---|---|
1 | ecnerwala | 3648 |
2 | Benq | 3580 |
3 | orzdevinwang | 3570 |
4 | cnnfls_csy | 3569 |
5 | Geothermal | 3568 |
6 | tourist | 3565 |
7 | maroonrk | 3530 |
8 | Radewoosh | 3520 |
9 | Um_nik | 3481 |
10 | jiangly | 3467 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 174 |
2 | awoo | 164 |
2 | adamant | 164 |
4 | TheScrasse | 159 |
4 | nor | 159 |
6 | maroonrk | 156 |
7 | -is-this-fft- | 150 |
8 | SecondThread | 147 |
9 | orz | 146 |
10 | pajenegod | 145 |
Hello Codeforces,
Whenever I click on any user profile, I see that that user has quite a bunch of friends. How do you guys know each other? How do you make friends?
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;
}
Name |
---|