-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1213B-Bad Prices.cpp
54 lines (42 loc) · 1.56 KB
/
1213B-Bad Prices.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
47
48
49
50
51
52
53
54
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//Definition Section
//--------------------------------------------------------------
#define fl(i,x,y) for(int i=x; i<y; i++)
#define flc(i,x,y,z) for(int i=x; i<y; i+=z)
#define nl cout<<endl
#define vsort(v) sort(v.begin(), v.end());
#define vsortg(v) sort(v.begin(), v.end(), greater<int>());
#define getIntoVc(v,n) { while(n--) {long long yyy; cin>>yyy; v.push_back(yyy);}}
#define all(x) x.begin(),x.end()
#define pb push_back
#define printvc(v) for(int i=0; i<v.size(); i++) cout<<v[i]<<" ";
#define strTOint(s,n) {stringstream sst; sst<<s; sst>>n;}
#define intTOstr(n,s) {stringstream sst; sst<<n; sst>>s;}
#define ff first
#define ss second
#define DouraMama {ios::sync_with_stdio(false); cin.tie(NULL);}
#define prefixSum(v,p) {long long sum=0; for(int i=0; i<v.size(); i++) {sum+=v[i];p.push_back(sum);}}
//--------------------------------------------------------------
int main()
{ DouraMama
ll n,m,t,i,j,k,x,y,z,a,b,c,cnt=0,ans=0;
bool flag=false;
string s,s1,s2,s3;
cin>>t;
while(t--) {
vector<ll> v;
cnt = 0;
cin >> n;
getIntoVc(v, n);
ans = v[v.size() - 1];
for (i = v.size() - 2; i >= 0; i--) {
if(v[i]>ans)
cnt++;
ans = min(ans, v[i]);
}
cout << cnt << endl;
}
//cout<<endl; main();
}