-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheight.cpp
46 lines (40 loc) · 914 Bytes
/
height.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
freopen("1.in","r",stdin);
int n; cin >> n;
while (n--) {
int counter = 0; int c;
cin >> c;
vector<int> v(20,0);
for (int i=0; i<20; i++) {
cin >> v[i];
}
for (int i=1; i<20; i++) {
int temp = v[i];
int j = i-1;
while (temp<v[j] && j>=0) {
v[j+1] = v[j];
j--;
counter++;
}
v[j+1] = temp;
}
cout << c << ' ' << counter << endl;
}
}