-
Notifications
You must be signed in to change notification settings - Fork 64
/
58_codechef_phone_prices.cpp
54 lines (52 loc) · 1.32 KB
/
58_codechef_phone_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
//
// main.cpp
// test1
//
// Created by Prince Kumar on 06/10/19.
// Copyright © 2019 Prince Kumar. All rights reserved.
//
// **-- October Long Challenge --**
// **-- Phone prices --**
#include <iostream>
using namespace std;
int main()
{
int T; cin>>T;
while(T--)
{
int n; cin>>n;
int a[n+1]; for(int i=1;i<=n;i++){cin>>a[i];}
// we have now prices on respective days
int count=1;
for(int i=2;i<=n;i++)
{
int price = a[i];
if(i==2)
{
if(price<a[i-1])
count++;
}
else if(i==3)
{
if(price<a[i-1] && price<a[i-2])
count++;
}
else if(i==4)
{
if(price<a[i-1] && price<a[i-2] && price<a[i-3])
count++;
}
else if(i==5)
{
if(price<a[i-1] && price<a[i-2] && price<a[i-3] && price<a[i-4])
count++;
}
else
{
if(price<a[i-1] && price<a[i-2] && price<a[i-3] && price<a[i-4] && price<a[i-5])
count++;
}
}
cout<<count<<endl;
}
}