fork(1) download
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5. unsigned long long num;
  6.  
  7. std::cin >> num;
  8.  
  9. unsigned int end = 0;
  10. unsigned int start = 0;
  11.  
  12. unsigned int tmpEnd = 0;
  13. unsigned int tmpStart = 0;
  14.  
  15. unsigned int length = 0;
  16. unsigned int tmpLength = 0;
  17.  
  18. unsigned int pos = 0;
  19. unsigned int cur = 9; // 0
  20.  
  21. while(num)
  22. {
  23. unsigned int c = num % 10;
  24.  
  25. if (c <= cur) // if (c >= cur)
  26. {
  27. cur = c;
  28. tmpEnd = pos;
  29. ++tmpLength;
  30. }
  31. else if (tmpLength > length)
  32. {
  33. length = tmpLength;
  34. end = tmpEnd;
  35. start = tmpStart;
  36.  
  37. tmpStart = pos;
  38. cur = 9; // 0
  39. tmpLength = 0;
  40. }
  41.  
  42. ++pos;
  43.  
  44. num = num/10;
  45. }
  46.  
  47. if (length < 2)
  48. {
  49. std::cout << "NO!!!" << std::endl;
  50. }
  51. else
  52. {
  53. std::cout << pos - end << ":" << pos - start << ":" << length << std::endl;
  54. }
  55.  
  56. return 0;
  57. }
Success #stdin #stdout 0s 3144KB
stdin
65432112345
stdout
6:11:6