about summary refs log tree commit diff
path: root/codechef/s10e.cc
diff options
context:
space:
mode:
authorNguyễn Gia Phong <vn.mcsinyx@gmail.com>2019-10-14 20:59:08 +0700
committerNguyễn Gia Phong <vn.mcsinyx@gmail.com>2019-10-14 20:59:08 +0700
commitcacc165173d67fa110766a555afe3020967d220c (patch)
treea859612503a5c4f4d870c074cc19d07b1eb3aed2 /codechef/s10e.cc
parent4b8df7227736b7c41af56e053d40decc309fe7f9 (diff)
downloadcp-cacc165173d67fa110766a555afe3020967d220c.tar.gz
Practice some C++
Diffstat (limited to 'codechef/s10e.cc')
-rw-r--r--codechef/s10e.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/codechef/s10e.cc b/codechef/s10e.cc
new file mode 100644
index 0000000..5e5c0b7
--- /dev/null
+++ b/codechef/s10e.cc
@@ -0,0 +1,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;
+}