diff options
Diffstat (limited to 'codechef')
77 files changed, 570 insertions, 0 deletions
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 diff --git a/codechef/Math1Enrolment/main.cpp b/codechef/Math1Enrolment/main.cpp new file mode 100644 index 0000000..4011941 --- /dev/null +++ b/codechef/Math1Enrolment/main.cpp @@ -0,0 +1,20 @@ +#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; + cin >> n >> m; + if(m <= n) { + cout << 0 << endl; + } else { + cout << m - n << endl; + } + + } +} diff --git a/codechef/Math1Enrolment/main_input0.txt b/codechef/Math1Enrolment/main_input0.txt new file mode 100644 index 0000000..2786035 --- /dev/null +++ b/codechef/Math1Enrolment/main_input0.txt @@ -0,0 +1,5 @@ +4 +1 1 +12 34 +50 49 +49 50 diff --git a/codechef/Math1Enrolment/main_output0.txt b/codechef/Math1Enrolment/main_output0.txt new file mode 100644 index 0000000..93edea2 --- /dev/null +++ b/codechef/Math1Enrolment/main_output0.txt @@ -0,0 +1,4 @@ +0 +22 +0 +1 diff --git a/codechef/MaximumWeightDifference/main b/codechef/MaximumWeightDifference/main Binary files differnew file mode 100755 index 0000000..e5ce1f4 --- /dev/null +++ b/codechef/MaximumWeightDifference/main diff --git a/codechef/MaximumWeightDifference/main.cpp b/codechef/MaximumWeightDifference/main.cpp new file mode 100644 index 0000000..751084c --- /dev/null +++ b/codechef/MaximumWeightDifference/main.cpp @@ -0,0 +1,32 @@ +#include <bits/stdc++.h> + +using namespace std; + +int sum(vector<int> &v, int start, int end) { + int sum = 0; + for(int i = start; i < end; i++) { + sum += v[i]; + } + return sum; +} + + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + int n, k; + cin >> n >> k; + vector<int> v(n); + for (int &x : v) + cin >> x; + sort(v.begin(), v.end()); + if(n == 1) { + cout << v[0]; + } else { + cout << sum(v, k, v.size()) - sum(v, 0, k) << endl; + } + } +} diff --git a/codechef/MaximumWeightDifference/main_input0.txt b/codechef/MaximumWeightDifference/main_input0.txt new file mode 100644 index 0000000..89c2c4e --- /dev/null +++ b/codechef/MaximumWeightDifference/main_input0.txt @@ -0,0 +1,5 @@ +2 +5 2 +8 4 5 2 10 +8 3 +1 1 1 1 1 1 1 1 diff --git a/codechef/MaximumWeightDifference/main_output0.txt b/codechef/MaximumWeightDifference/main_output0.txt new file mode 100644 index 0000000..f1f71f3 --- /dev/null +++ b/codechef/MaximumWeightDifference/main_output0.txt @@ -0,0 +1,2 @@ +17 +2 diff --git a/codechef/RacingHorses/main b/codechef/RacingHorses/main Binary files differnew file mode 100755 index 0000000..a071dd7 --- /dev/null +++ b/codechef/RacingHorses/main diff --git a/codechef/RacingHorses/main.cpp b/codechef/RacingHorses/main.cpp new file mode 100644 index 0000000..1da09f4 --- /dev/null +++ b/codechef/RacingHorses/main.cpp @@ -0,0 +1,22 @@ +#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; + sort(v.begin(), v.end()); + int mn = 1e9; + for(int i = 0; i < n - 1; i++) { + mn = min(mn, abs(v[i] - v[i + 1])); + } + cout << mn << endl; + } +} diff --git a/codechef/RacingHorses/main_input0.txt b/codechef/RacingHorses/main_input0.txt new file mode 100644 index 0000000..3142f24 --- /dev/null +++ b/codechef/RacingHorses/main_input0.txt @@ -0,0 +1,3 @@ +1 +5 +4 9 1 32 13
\ No newline at end of file diff --git a/codechef/RacingHorses/main_output0.txt b/codechef/RacingHorses/main_output0.txt new file mode 100644 index 0000000..e440e5c --- /dev/null +++ b/codechef/RacingHorses/main_output0.txt @@ -0,0 +1 @@ +3
\ No newline at end of file diff --git a/codechef/SnakeProcession/inp b/codechef/SnakeProcession/inp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/codechef/SnakeProcession/inp |
