fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <set>
  5. #include <stdio.h>
  6.  
  7. using namespace std;
  8.  
  9. int main() {
  10. int n;
  11. bool t=false;
  12. int dorg=0;
  13. scanf("%d",&n);
  14. for(int i=0; i<n; i++){
  15. int x;
  16. scanf("%d",&x);
  17. if(x==25){
  18. dorg+=25;
  19. t=true;
  20. }
  21. else if(x==50&&dorg<25){
  22. t=false;
  23. break;
  24. }
  25. else if(x==50&&dorg>=25){
  26. dorg+=25;
  27. t=true;
  28. }
  29. else if(x==100&&dorg<75){
  30. t=false;
  31. break;
  32. }
  33. else if(x==100&&dorg>=75){
  34. dorg+=25;
  35. t=true;
  36. }
  37. }
  38. if(t){printf("YES\n");}
  39. else {printf("NO\n");}
  40. return 0;
  41. }
Success #stdin #stdout 0s 3416KB
stdin
3
25 50 50
stdout
YES