-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathlong atm queue
More file actions
50 lines (40 loc) · 1.48 KB
/
long atm queue
File metadata and controls
50 lines (40 loc) · 1.48 KB
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
/*
Due to the demonetization move, there is a long queue of people in front of ATMs. Due to withdrawal limit per person per day, people come in
groups to withdraw money. Groups come one by one and line up behind the already present queue. The groups have a strange way of arranging
themselves. In a particular group, the group members arrange themselves in increasing order of their height(not necessarily strictly increasing).
Swapy observes a long queue standing in front of the ATM near his house. Being a curious kid, he wants to count the total number of groups
present in the queue waiting to withdraw money. Since groups are standing behind each other, one cannot differentiate between different groups
and the exact count cannot be given. Can you tell him the minimum number of groups that can be observed in the queue?
Input format:
The first line of input contains one positive integer N. The second line contains N space-separated integers H[i] denoting the height of i-th
person. Each group has group members standing in increasing order of their height.
Output format:
Print the minimum number of groups that are at least present in the queue?
Constraints:
1≤N≤1,000,000
1≤H[i]≤1,000,000
SAMPLE INPUT
4
1 2 3 4
SAMPLE OUTPUT
1
Explanation
1
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int a[n],i,c=1;
for(i=0;i<n;i++)
{
cin>>a[i];
}
for(i=0;i<n-1;i++)
{
if(a[i+1]<a[i]) c++;
}
cout<<c<<endl;
}