-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTask.cpp
More file actions
40 lines (35 loc) · 769 Bytes
/
Task.cpp
File metadata and controls
40 lines (35 loc) · 769 Bytes
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
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
int f=1;
while(t--)
{
int n;
cin>>n;
int a[n];
for(int i =0;i<n;i++)
{
cin>>a[i];
}
int c=0,count=0;
for(int i=0;i<n-1;i++)
{
for(int j=0;j<n;j++)
{
int min =0;
min = *min_element(a+i,a+n);
if(a[j]==min)
{
reverse(a+i,a+j+1);
c = j-i+1;
count+=c;
}
}
}
cout<<"Case #"<<f<<": "<<count<<endl;
f++;
}
return 0;
}