Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Просто решаю.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
- //
- //KiruxaLight
- #define _CRT_SECURE_NO_WARNINGS
- #define _USE_MATH_DEFINES
- #include <iostream>
- #include <vector>
- #include <string>
- #include <set>
- #include <map>
- #include <algorithm>
- #include <utility>
- #include <cmath>
- #include <iomanip>
- #include <stack>
- #include <deque>
- #include <queue>
- #include <cstdio>
- #include <unordered_map>
- #include <unordered_set>
- #include <numeric>
- #include <cassert>
- using namespace std;
- #define int long long
- #define all(a) a.begin(), a.end()
- #define rall(a) a.rbegin(), a.rend()
- const int INF = 1e9 + 123, MAXN = 2e5 + 47, MEGAINF = 1e18;
- template <class T>
- inline istream& operator >> (istream& in, vector <T>& a)
- {
- for (auto& i : a)
- in >> i;
- return in;
- }
- template <class T>
- inline ostream& operator << (ostream& out, vector <T>& a)
- {
- for (auto& i : a)
- out << i << " ";
- return out;
- }
- template <class T, class U>
- inline istream& operator >> (istream& in, vector <pair <T, U>>& a)
- {
- for (auto& i : a)
- in >> i.first >> i.second;
- return in;
- }
- template <class T, class U>
- inline ostream& operator << (ostream& out, vector <pair <T, U>>& a)
- {
- for (auto& i : a)
- out << i.first << " " << i.second << endl;
- return out;
- }
- signed main()
- {
- setlocale(LC_ALL, "rus");
- /*freopen(".in", "r", stdin);
- freopen(".out", "w", stdout);*/
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- int n;
- cin >> n;
- vector <int> a(n);
- cin >> a;
- vector <int> plus, minus;
- for (int i = 0; i < n; ++i)
- if (a[i] > 0)
- plus.push_back(i);
- else if (a[i] < 0)
- minus.push_back(i);
- int ans = 0;
- cout << plus << endl << minus << endl;
- int cnt = 1;
- for (int i = 1; i < plus.size(); ++i)
- if (plus[i] - 1 == plus[i - 1])
- ++cnt;
- else
- {
- ans += cnt * (cnt + 1) / 2;
- cnt = 1;
- }
- ans += cnt * (cnt + 1) / 2;
- cnt = 1;
- for (int i = 1; i < minus.size(); ++i)
- if (minus[i] - 1 == minus[i - 1])
- ++cnt;
- else
- {
- ans += cnt * (cnt + 1) / 2;
- cnt = 1;
- }
- ans += cnt * (cnt + 1) / 2;
- cnt = 1;
- cout << ans;
- }
- // Запуск программы: CTRL+F5 или меню "Отладка" > "Запуск без отладки"
- // Отладка программы: F5 или меню "Отладка" > "Запустить отладку"
- // Советы по началу работы
- // 1. В окне обозревателя решений можно добавлять файлы и управлять ими.
- // 2. В окне Team Explorer можно подключиться к системе управления версиями.
- // 3. В окне "Выходные данные" можно просматривать выходные данные сборки и другие сообщения.
- // 4. В окне "Список ошибок" можно просматривать ошибки.
- // 5. Последовательно выберите пункты меню "Проект" > "Добавить новый элемент", чтобы создать файлы кода, или "Проект" > "Добавить существующий элемент", чтобы добавить в проект существующие файлы кода.
- // 6. Чтобы снова открыть этот проект позже, выберите пункты меню "Файл" > "Открыть" > "Проект" и выберите SLN-файл.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement