diff options
| author | omagdy7 <omar.professional8777@gmail.com> | 2022-07-08 19:54:42 +0200 |
|---|---|---|
| committer | omagdy7 <omar.professional8777@gmail.com> | 2022-07-08 19:54:42 +0200 |
| commit | dd684349c67c988ef19707cb65e637b6906fac75 (patch) | |
| tree | 2fd9ac45ef08351c8164eda640dade2890f4c731 | |
| parent | 4688ed5f3a56ac6698250e2169adbfbe53b8b685 (diff) | |
| download | competitive-programming-dd684349c67c988ef19707cb65e637b6906fac75.tar.xz competitive-programming-dd684349c67c988ef19707cb65e637b6906fac75.zip | |
Solved some new problems
83 files changed, 624 insertions, 0 deletions
diff --git a/HackerRank/Mini-MaxSum/main b/HackerRank/Mini-MaxSum/main Binary files differnew file mode 100755 index 0000000..381d317 --- /dev/null +++ b/HackerRank/Mini-MaxSum/main diff --git a/HackerRank/Mini-MaxSum/main.cpp b/HackerRank/Mini-MaxSum/main.cpp new file mode 100644 index 0000000..1231c85 --- /dev/null +++ b/HackerRank/Mini-MaxSum/main.cpp @@ -0,0 +1,23 @@ +#include <bits/stdc++.h> + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + vector<int> v(5); + for (int &x : v) { + cin >> x; + } + sort(v.begin(), v.end()); + int sumMin = 0, sumMax = 0; + for (int i = 0; i < 5; i++) { + if (v[i] != v[0]) { + sumMax += v[i]; + } + if (v[i] != v[4]) { + sumMin += v[i]; + } + } + cout << sumMin << " " << sumMax << endl; +} diff --git a/HackerRank/PlusMinus/main b/HackerRank/PlusMinus/main Binary files differnew file mode 100755 index 0000000..808d60e --- /dev/null +++ b/HackerRank/PlusMinus/main diff --git a/HackerRank/PlusMinus/main.cpp b/HackerRank/PlusMinus/main.cpp new file mode 100644 index 0000000..1d5d7e5 --- /dev/null +++ b/HackerRank/PlusMinus/main.cpp @@ -0,0 +1,24 @@ +#include <bits/stdc++.h> + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int n; + cin >> n; + vector<int> v(n); + for (auto &x : v) + cin >> x; + double plus = 0, minus = 0, zero = 0; + for (int x : v) { + if (x < 0) { + minus++; + } else if (x > 0) { + plus++; + } else { + zero++; + } + } + printf("%.6f\n%.6f\n%.6f\n", plus / n, minus / n, zero / n); +} diff --git a/HackerRank/PlusMinus/main_input0.txt b/HackerRank/PlusMinus/main_input0.txt new file mode 100644 index 0000000..db80860 --- /dev/null +++ b/HackerRank/PlusMinus/main_input0.txt @@ -0,0 +1,4 @@ +STDIN Function +----- -------- +6 arr[] size n = 6 +-4 3 -9 0 4 1 arr = [-4, 3, -9, 0, 4, 1] diff --git a/HackerRank/PlusMinus/main_output0.txt b/HackerRank/PlusMinus/main_output0.txt new file mode 100644 index 0000000..b098de6 --- /dev/null +++ b/HackerRank/PlusMinus/main_output0.txt @@ -0,0 +1,3 @@ +0.500000 +0.333333 +0.166667 diff --git a/codechef/ArmyTraining/main b/codechef/ArmyTraining/main Binary files differnew file mode 100755 index 0000000..527b3b4 --- /dev/null +++ b/codechef/ArmyTraining/main diff --git a/codechef/ArmyTraining/main.cpp b/codechef/ArmyTraining/main.cpp new file mode 100644 index 0000000..a85f4f3 --- /dev/null +++ b/codechef/ArmyTraining/main.cpp @@ -0,0 +1,25 @@ +#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; + long long att = 0; + long long def = 0; + for(int i = 0; i < n; i++) { + int x; + cin >> x; + if(x <= 500) { + def += 1000 - x; + } else { + att += x; + } + } + } +} diff --git a/codechef/ArmyTraining/main_input0.txt b/codechef/ArmyTraining/main_input0.txt new file mode 100644 index 0000000..551ceff --- /dev/null +++ b/codechef/ArmyTraining/main_input0.txt @@ -0,0 +1,9 @@ +4 +2 +500 500 +3 +500 500 500 +4 +100 800 300 500 +4 +300 700 800 200 diff --git a/codechef/ArmyTraining/main_output0.txt b/codechef/ArmyTraining/main_output0.txt new file mode 100644 index 0000000..cbc7a89 --- /dev/null +++ b/codechef/ArmyTraining/main_output0.txt @@ -0,0 +1,4 @@ +250000 +500000 +2080000 +2250000 diff --git a/codechef/ChefAndFeedBack/inp b/codechef/ChefAndFeedBack/inp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/codechef/ChefAndFeedBack/inp diff --git a/codechef/ChefAndFeedBack/main b/codechef/ChefAndFeedBack/main Binary files differnew file mode 100755 index 0000000..c3c70a2 --- /dev/null +++ b/codechef/ChefAndFeedBack/main diff --git a/codechef/ChefAndFeedBack/main.cpp b/codechef/ChefAndFeedBack/main.cpp new file mode 100644 index 0000000..8f04fc8 --- /dev/null +++ b/codechef/ChefAndFeedBack/main.cpp @@ -0,0 +1,24 @@ +#include<bits/stdc++.h> + + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + string str1 = "010"; + string str2 = "101"; + while(tt--){ + string s; + cin >> s; + int found1 = s.find(str1); + int found2 = s.find(str2); + if(found1 != string::npos || found2 != string::npos) { + cout << "Good" << endl; + } else { + cout << "Bad" << endl; + } + } +} diff --git a/codechef/ChefAndFeedBack/main.py b/codechef/ChefAndFeedBack/main.py new file mode 100644 index 0000000..afde99f --- /dev/null +++ b/codechef/ChefAndFeedBack/main.py @@ -0,0 +1,8 @@ +t = int(input()) +for i in range(t): + s = input() + if "101" in s or "010" in s: + print("Good") + else: + print("Bad") + diff --git a/codechef/ChefAndFeedBack/main_input0.txt b/codechef/ChefAndFeedBack/main_input0.txt new file mode 100644 index 0000000..16405d6 --- /dev/null +++ b/codechef/ChefAndFeedBack/main_input0.txt @@ -0,0 +1,3 @@ +2 +11111110 +10101010101010 diff --git a/codechef/ChefAndFeedBack/main_output0.txt b/codechef/ChefAndFeedBack/main_output0.txt new file mode 100644 index 0000000..c985d56 --- /dev/null +++ b/codechef/ChefAndFeedBack/main_output0.txt @@ -0,0 +1,2 @@ +Bad +Good diff --git a/codechef/ComplementaryStrandInDna/a.out b/codechef/ComplementaryStrandInDna/a.out Binary files differnew file mode 100755 index 0000000..7eb82fa --- /dev/null +++ b/codechef/ComplementaryStrandInDna/a.out diff --git a/codechef/CountSubstrings/inp b/codechef/CountSubstrings/inp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/codechef/CountSubstrings/inp diff --git a/codechef/CountSubstrings/main b/codechef/CountSubstrings/main Binary files differnew file mode 100755 index 0000000..16c37e0 --- /dev/null +++ b/codechef/CountSubstrings/main diff --git a/codechef/CountSubstrings/main.cpp b/codechef/CountSubstrings/main.cpp new file mode 100644 index 0000000..8ee40d2 --- /dev/null +++ b/codechef/CountSubstrings/main.cpp @@ -0,0 +1,18 @@ +#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; + string s; + cin >> s; + long long x = count(s.begin(), s.end(), '1'); + cout << (x * (x+1)) /2 << endl; + } +} diff --git a/codechef/CountSubstrings/main_input0.txt b/codechef/CountSubstrings/main_input0.txt new file mode 100644 index 0000000..dcf608b --- /dev/null +++ b/codechef/CountSubstrings/main_input0.txt @@ -0,0 +1,5 @@ +2 +4 +1111 +5 +10001 diff --git a/codechef/CountSubstrings/main_output0.txt b/codechef/CountSubstrings/main_output0.txt new file mode 100644 index 0000000..24350e0 --- /dev/null +++ b/codechef/CountSubstrings/main_output0.txt @@ -0,0 +1,2 @@ +10 +3 diff --git a/codechef/EquinoxStrings/inp b/codechef/EquinoxStrings/inp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/codechef/EquinoxStrings/inp diff --git a/codechef/EquinoxStrings/main b/codechef/EquinoxStrings/main Binary files differnew file mode 100755 index 0000000..ce92096 --- /dev/null +++ b/codechef/EquinoxStrings/main diff --git a/codechef/EquinoxStrings/main.cpp b/codechef/EquinoxStrings/main.cpp new file mode 100644 index 0000000..574b656 --- /dev/null +++ b/codechef/EquinoxStrings/main.cpp @@ -0,0 +1,34 @@ +#include <bits/stdc++.h> + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + string w = "EQUINOX"; + while (tt--) { + int n, a, b; + cin >> n >> a >> b; + cerr << b << endl; + long long an = 0, sa = 0; + for (int i = 0; i < n; i++) { + string s; + cin >> s; + if(w.find(s[0]) != string::npos) { + sa += a; + } else { + an += b; + } + } + cerr << an << " " << sa << endl; + if (an > sa) { + cout << "ANURADHA" << endl; + } else if(an < sa) { + cout << "SARTHAK" << endl; + } else { + cout << "DRAW" << endl; + } + } +} diff --git a/codechef/EquinoxStrings/main_input0.txt b/codechef/EquinoxStrings/main_input0.txt new file mode 100644 index 0000000..6325e0d --- /dev/null +++ b/codechef/EquinoxStrings/main_input0.txt @@ -0,0 +1,9 @@ +2 +4 1 3 +ABBBCDDE +EARTH +INDIA +UUUFFFDDD +2 5 7 +SDHHD +XOXOXOXO diff --git a/codechef/EquinoxStrings/main_output0.txt b/codechef/EquinoxStrings/main_output0.txt new file mode 100644 index 0000000..67bb96a --- /dev/null +++ b/codechef/EquinoxStrings/main_output0.txt @@ -0,0 +1,2 @@ +DRAW +ANURADHA diff --git a/codechef/HiringTest/inp b/codechef/HiringTest/inp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/codechef/HiringTest/inp diff --git a/codechef/HiringTest/main b/codechef/HiringTest/main Binary files differnew file mode 100755 index 0000000..7bf6644 --- /dev/null +++ b/codechef/HiringTest/main diff --git a/codechef/HiringTest/main.cpp b/codechef/HiringTest/main.cpp new file mode 100644 index 0000000..e5a08a8 --- /dev/null +++ b/codechef/HiringTest/main.cpp @@ -0,0 +1,27 @@ +#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, m, x, y; + cin >> n >> m >> x >> y; + string ans = ""; + for(int i = 0; i < n; i++) { + string pb; + cin >> pb; + int f = count(pb.begin(), pb.end(), 'F'); + int p = count(pb.begin(), pb.end(), 'P'); + if(f >= x || f == x - 1 && p >= y) { + ans.push_back('1'); + } else { + ans.push_back('0'); + } + } + cout << ans << endl; + } +} diff --git a/codechef/HiringTest/main_input0.txt b/codechef/HiringTest/main_input0.txt new file mode 100644 index 0000000..46cc6c4 --- /dev/null +++ b/codechef/HiringTest/main_input0.txt @@ -0,0 +1,15 @@ +3 +4 5 +3 2 +FUFFP +PFPFU +UPFFU +PPPFP +3 4 +1 3 +PUPP +UUUU +UFUU +1 3 +2 2 +PPP diff --git a/codechef/HiringTest/main_output0.txt b/codechef/HiringTest/main_output0.txt new file mode 100644 index 0000000..171c34b --- /dev/null +++ b/codechef/HiringTest/main_output0.txt @@ -0,0 +1,3 @@ +1100 +101 +0 diff --git a/codechef/Lapindromes/inp b/codechef/Lapindromes/inp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/codechef/Lapindromes/inp diff --git a/codechef/Lapindromes/main b/codechef/Lapindromes/main Binary files differnew file mode 100755 index 0000000..4214922 --- /dev/null +++ b/codechef/Lapindromes/main diff --git a/codechef/Lapindromes/main.cpp b/codechef/Lapindromes/main.cpp new file mode 100644 index 0000000..d00f9e6 --- /dev/null +++ b/codechef/Lapindromes/main.cpp @@ -0,0 +1,37 @@ +#include<bits/stdc++.h> + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + string s; + cin >> s; + int l = s.size(); + string le, ri; + if(l & 1) { + le = s.substr(0, l / 2); + ri = s.substr((l / 2) + 1, l); + } else { + le = s.substr(0, l / 2); + ri = s.substr(l / 2, l); + } + int ok = 1; + set<char> st; + for(int i = 0; i < le.size(); i++) { + st.insert(le[i]); + } + for(auto x : st) { + int ls = count(le.begin(), le.end(), x); + int rs = count(ri.begin(), ri.end(), x); + if(ls != rs) { + ok = 0; + break; + } + } + cout << (ok ? "YES" : "NO") << endl; + } +} diff --git a/codechef/Lapindromes/main_input0.txt b/codechef/Lapindromes/main_input0.txt new file mode 100644 index 0000000..2776e7b --- /dev/null +++ b/codechef/Lapindromes/main_input0.txt @@ -0,0 +1,7 @@ +6 +gaga +abcde +rotor +xyzxy +abbaab +ababc diff --git a/codechef/Lapindromes/main_output0.txt b/codechef/Lapindromes/main_output0.txt new file mode 100644 index 0000000..faa6105 --- /dev/null +++ b/codechef/Lapindromes/main_output0.txt @@ -0,0 +1,6 @@ +YES +NO +YES +YES +NO +NO diff --git a/codechef/Math1Enrolment/main b/codechef/Math1Enrolment/main Binary files differnew file mode 100755 index 0000000..74a2133 --- /dev/null +++ b/codechef/Math1Enrolment/main |
