Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //mateusz Lesniczak pocztowka
- #include <iostream>
- #include <vector>
- using namespace std;
- bool czy_jest(int start, int koniec, vector<int> numery)
- {
- int n = numery.size(); // numery.size() - zwraca ile jest elementów w wektorze
- for(int i = 0; i < n; ++i)
- if(numery[i] >= start && numery[i] <= koniec)
- return true;
- return false;
- }
- int main()
- {
- int n, m, liczba, sukcesy = 0;
- cin >> n >> m;
- vector<int> numery;
- for(int i = 0; i < n; ++i)
- {
- cin >> liczba;
- if(liczba >= m)
- numery.push_back(i); // dodanie elementu na koniec tablicy
- }
- for(int l = 0; l < n; ++l)
- for(int p = 0; l + p < n; ++p)
- {
- if(czy_jest(l, n - 1 - p, numery))
- ++sukcesy;
- else
- break;
- }
- cout << sukcesy;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment