diff options
| author | Omar Magdy <omar.professional8777@gmail.com> | 2022-06-02 14:06:48 +0200 |
|---|---|---|
| committer | Omar Magdy <omar.professional8777@gmail.com> | 2022-06-02 14:06:48 +0200 |
| commit | 5b2d58b6f42a19b4c779627d71a1158e4376699d (patch) | |
| tree | e19f8e04ba6de7d291ee394f233064ec7dec410a /codechef/averageFlex/main.cpp | |
| parent | dc0f2c7d7b6c4e6aa5956de3e783c85fb71a8eaf (diff) | |
| download | competitive-programming-5b2d58b6f42a19b4c779627d71a1158e4376699d.tar.xz competitive-programming-5b2d58b6f42a19b4c779627d71a1158e4376699d.zip | |
Solved Average flex from codechef
Diffstat (limited to 'codechef/averageFlex/main.cpp')
| -rw-r--r-- | codechef/averageFlex/main.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/codechef/averageFlex/main.cpp b/codechef/averageFlex/main.cpp new file mode 100644 index 0000000..2acb1f2 --- /dev/null +++ b/codechef/averageFlex/main.cpp @@ -0,0 +1,35 @@ +#include <bits/stdc++.h> + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + int n; + cin >> n; + vector<int> v(n); + for (int &x : v) + cin >> x; + map<int, int> low; + map<int, int> high; + for (int i = 0; i < v.size(); i++) { + for (int j = 0; j < v.size(); j++) { + if (v[j] <= v[i]) { + high[v[i]]++; + } else { + low[v[i]]++; + } + } + } + int count = 0; + for(int x : v) { + if(low[x] < high[x]) { + count++; + } + } + cout << count << endl; + } +} |
