We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
You can remove the "check" variable and just compare against 0 using k:
intmain(){intt;cin>>t;for(inta0=0;a0<t;a0++){intn;intk;cin>>n>>k;vector<int>a(n);for(inta_i=0;a_i<n;a_i++){cin>>a[a_i];}// Subtract from K if student is ON timefor(inti=0;i<n;++i){if(a[i]<=0){// STUDENT ON TIME--k;}}if(k<=0){cout<<"NO"<<endl;}else{cout<<"YES"<<endl;}}return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Angry Professor
You are viewing a single comment's thread. Return to all comments →
You can remove the "check" variable and just compare against 0 using k: