about summary refs log tree commit diff
path: root/codechef/s10e.cc
blob: 5e5c0b741150cfd093953ef5d7657d1f296c9f5f (plain) (blame)
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
#include <algorithm>
#include <deque>
#include <iostream>

using namespace std;

int
main()
{
  int t;
  int tmp;
  deque<int> p;

  cin >> t;
  while (t--)
    {
      int n;
      int r = 0;

      cin >> n;
      p.clear();
      while (n--)
        {
          cin >> tmp;
          auto it = min_element (p.begin(), p.end());
          r += it == p.end() || *it > tmp;
          p.push_back (tmp);
          if (p.size() > 5)
            p.pop_front();
        }
      cout << r << endl;
    }

  return 0;
}