fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5.  
  6.  
  7. int main(){
  8. int n;
  9. cin >> n;
  10. vector<int> a(n);
  11. for(int i = 0; i < n; i++){
  12. cin >> a[i];
  13. }
  14. int cnt = 0;
  15. int res = 0;
  16. int solug = 0; //
  17. for(int i = 0; i < n; i++){
  18. if(i == 0){
  19. if(a[i] != 0){
  20. if(res > cnt){
  21. res = cnt;
  22. solug = 1;
  23. }
  24. else if(res != 0&&res == cnt){
  25. solug++;
  26. }
  27. cnt = 1;
  28.  
  29. }
  30. }
  31. else{
  32. if(a[i] * a[i-1] < 0){
  33. cnt++;
  34. }
  35. else{
  36. if(a[i] != 0){
  37. if(res < cnt){
  38. res = cnt;
  39. solug = 1;
  40. }
  41. else if(res != 0&&res == cnt){
  42. solug++;
  43. }
  44. cnt = 1;
  45. }
  46. else{
  47. if(res < cnt){
  48. res = cnt;
  49. solug = 1;
  50. }
  51. else if(res != 0&&res == cnt){
  52. solug++;
  53. }
  54. cnt = 0;
  55. }
  56.  
  57. }
  58. }
  59. // cout << "i: " << i << " cnt: " << cnt << " res: " << res << " solug: " << solug << "\n";
  60. }
  61. if(res < cnt){
  62. res = cnt;
  63. solug = 1;
  64. }
  65. else if(res != 0&&res == cnt){
  66. solug++;
  67. }
  68. cout << solug << " " << res << "\n";
  69. return 0;
  70. }
  71.  
  72.  
  73.  
  74.  
  75.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
0 0