Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. int main(){
  5. int n = 0;
  6. int upper_limit = 0;
  7. int i = 0;
  8. int j = 0;
  9. std::cin >> n;
  10.  
  11. std::vector<int> s(n); // secventa
  12. std::vector<int> v(n); // aparitii
  13.  
  14. for (i = 0; i < n; i++) {
  15. v[i] = 0;
  16. }
  17.  
  18. for (i = 0; i < n; i++) {
  19. std::cin >> s[i];
  20.  
  21. for (i = 0; i < n; i++) {
  22. if (s[i] == 0) {
  23. j++;
  24. }
  25. else {
  26. if (j == 0) {
  27. continue;
  28. } else {
  29. v[j] += 1;
  30. upper_limit = j;
  31. j = 0;
  32. }
  33. }
  34. }
  35.  
  36. for (i = 1; i <= upper_limit; i++) {
  37. cout << v[j] << " ";
  38. }
  39. cout << endl;
  40.  
  41. for (i = 1; i < upper_limit; i++) {
  42. if (v[i] < v[i+1]) {
  43. break;
  44. }
  45. }
  46. if (i == upper_limit) {
  47. cout << "1";
  48. }
  49. else {
  50. cout << "0";
  51. }
  52. return 0;
  53. }
  54.  
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement