Valera and Plates (369A - Valera and Plates)

  1. 369A - Valera and Plates

  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. int main(){
  5. int n,b,p,bowl=0,plate=0;
  6. cin>>n>>b>>p;
  7. int a;
  8. for(int j=0;j<n;j++){
  9. cin>>a;
  10. if(a==1){
  11. bowl++;
  12. }
  13. else plate++;
  14. }
  15. int x,y,ans=0;;
  16. x = b- bowl;
  17. if(x>0) p = x+p;
  18. else if(x<0) ans= abs(x);
  19. if(plate >0)
  20. p = p -plate;
  21. if(p<0) ans = ans+ abs(p);
  22.  
  23. cout<<ans;
  24. }

Comments

Popular posts from this blog

Codeforce Problem 1703A. YES or YES?

Aptitude test assistant programmer 2018

1041A. Heist solution