Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- using ll = long long;
- int main()
- {
- ll t;
- cin >> t;
- ll x;
- deque<ll> z1;
- while (t-- > 0)
- {
- cin >> x;
- ll sum = 0;
- ll a, nbn = 20;
- while (nbn-- > 0)
- {
- cin >> a;
- z1.push_back(a);
- }
- while (true)
- {
- ll val = 1;
- for (int i = 0; i < 19; i++)
- {
- if (z1.at(i) > z1.at(i + 1))
- {
- swap(z1.at(i), z1.at(i++));
- val = 0;
- sum += 1;
- }
- }
- if (val == 1)
- {
- break;
- }
- }
- cout << x << " " << sum << '\n';
- z1.clear();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment