Advertisement
halexandru11

var6 ultimul ex

Apr 19th, 2021
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. ifstream fin("date.in");
  8. long x;
  9. int ans = 0;
  10. int start = 0, sfarsit = 0, negativ = -1;
  11. for(int i = 0; fin >> x; ++i) {
  12. if(x < 0) {
  13. int interval = sfarsit - start + 1;
  14. if(interval > ans) {
  15. ans = interval;
  16. }
  17. start = negativ + 1;
  18. negativ = i;
  19. }
  20. sfarsit = i;
  21. }
  22. cout << ans;
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement