aboutsummaryrefslogtreecommitdiff
path: root/codechef
diff options
context:
space:
mode:
Diffstat (limited to 'codechef')
-rwxr-xr-xcodechef/ArmyTraining/mainbin0 -> 22576 bytes
-rw-r--r--codechef/ArmyTraining/main.cpp25
-rw-r--r--codechef/ArmyTraining/main_input0.txt9
-rw-r--r--codechef/ArmyTraining/main_output0.txt4
-rw-r--r--codechef/ChefAndFeedBack/inp0
-rwxr-xr-xcodechef/ChefAndFeedBack/mainbin0 -> 30544 bytes
-rw-r--r--codechef/ChefAndFeedBack/main.cpp24
-rw-r--r--codechef/ChefAndFeedBack/main.py8
-rw-r--r--codechef/ChefAndFeedBack/main_input0.txt3
-rw-r--r--codechef/ChefAndFeedBack/main_output0.txt2
-rwxr-xr-xcodechef/ComplementaryStrandInDna/a.outbin0 -> 83728 bytes
-rw-r--r--codechef/CountSubstrings/inp0
-rwxr-xr-xcodechef/CountSubstrings/mainbin0 -> 24688 bytes
-rw-r--r--codechef/CountSubstrings/main.cpp18
-rw-r--r--codechef/CountSubstrings/main_input0.txt5
-rw-r--r--codechef/CountSubstrings/main_output0.txt2
-rw-r--r--codechef/EquinoxStrings/inp0
-rwxr-xr-xcodechef/EquinoxStrings/mainbin0 -> 30696 bytes
-rw-r--r--codechef/EquinoxStrings/main.cpp34
-rw-r--r--codechef/EquinoxStrings/main_input0.txt9
-rw-r--r--codechef/EquinoxStrings/main_output0.txt2
-rw-r--r--codechef/HiringTest/inp0
-rwxr-xr-xcodechef/HiringTest/mainbin0 -> 31976 bytes
-rw-r--r--codechef/HiringTest/main.cpp27
-rw-r--r--codechef/HiringTest/main_input0.txt15
-rw-r--r--codechef/HiringTest/main_output0.txt3
-rw-r--r--codechef/Lapindromes/inp0
-rwxr-xr-xcodechef/Lapindromes/mainbin0 -> 45968 bytes
-rw-r--r--codechef/Lapindromes/main.cpp37
-rw-r--r--codechef/Lapindromes/main_input0.txt7
-rw-r--r--codechef/Lapindromes/main_output0.txt6
-rwxr-xr-xcodechef/Math1Enrolment/mainbin0 -> 22576 bytes
-rw-r--r--codechef/Math1Enrolment/main.cpp20
-rw-r--r--codechef/Math1Enrolment/main_input0.txt5
-rw-r--r--codechef/Math1Enrolment/main_output0.txt4
-rwxr-xr-xcodechef/MaximumWeightDifference/mainbin0 -> 44720 bytes
-rw-r--r--codechef/MaximumWeightDifference/main.cpp32
-rw-r--r--codechef/MaximumWeightDifference/main_input0.txt5
-rw-r--r--codechef/MaximumWeightDifference/main_output0.txt2
-rwxr-xr-xcodechef/RacingHorses/mainbin0 -> 44616 bytes
-rw-r--r--codechef/RacingHorses/main.cpp22
-rw-r--r--codechef/RacingHorses/main_input0.txt3
-rw-r--r--codechef/RacingHorses/main_output0.txt1
-rw-r--r--codechef/SnakeProcession/inp0
-rwxr-xr-xcodechef/SnakeProcession/mainbin0 -> 604248 bytes
-rw-r--r--codechef/SnakeProcession/main.cpp18
-rw-r--r--codechef/SnakeProcession/main_input0.txt13
-rw-r--r--codechef/SnakeProcession/main_output0.txt6
-rwxr-xr-xcodechef/SortTheString/mainbin0 -> 603200 bytes
-rw-r--r--codechef/SortTheString/main.cpp24
-rw-r--r--codechef/SortTheString/main_input0.txt9
-rw-r--r--codechef/SortTheString/main_output0.txt4
-rw-r--r--codechef/StudyingAlphabet/inp0
-rwxr-xr-xcodechef/StudyingAlphabet/mainbin0 -> 24048 bytes
-rw-r--r--codechef/StudyingAlphabet/main.cpp25
-rw-r--r--codechef/StudyingAlphabet/main_input0.txt4
-rw-r--r--codechef/StudyingAlphabet/main_output0.txt2
-rwxr-xr-xcodechef/TheSmallestPair/mainbin0 -> 44568 bytes
-rw-r--r--codechef/TheSmallestPair/main.cpp18
-rw-r--r--codechef/TheSmallestPair/main_input0.txt3
-rw-r--r--codechef/TheSmallestPair/main_output0.txt1
-rwxr-xr-xcodechef/countingWords/mainbin0 -> 22576 bytes
-rw-r--r--codechef/countingWords/main.cpp15
-rw-r--r--codechef/countingWords/main_input0.txt5
-rw-r--r--codechef/countingWords/main_output0.txt4
-rwxr-xr-xcodechef/groupAssignment/mainbin0 -> 56192 bytes
-rw-r--r--codechef/groupAssignment/main.cpp35
-rw-r--r--codechef/groupAssignment/main_input0.txt9
-rw-r--r--codechef/groupAssignment/main_input1.txt9
-rw-r--r--codechef/groupAssignment/main_input2.txt3
-rw-r--r--codechef/groupAssignment/main_input3.txt3
-rw-r--r--codechef/groupAssignment/main_input4.txt11
-rw-r--r--codechef/groupAssignment/main_output0.txt4
-rw-r--r--codechef/groupAssignment/main_output1.txt4
-rw-r--r--codechef/groupAssignment/main_output2.txt1
-rw-r--r--codechef/groupAssignment/main_output3.txt1
-rw-r--r--codechef/groupAssignment/main_output4.txt5
77 files changed, 570 insertions, 0 deletions
diff --git a/codechef/ArmyTraining/main b/codechef/ArmyTraining/main
new file mode 100755
index 0000000..527b3b4
--- /dev/null
+++ b/codechef/ArmyTraining/main
Binary files differ
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
new file mode 100755
index 0000000..c3c70a2
--- /dev/null
+++ b/codechef/ChefAndFeedBack/main
Binary files differ
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
new file mode 100755
index 0000000..7eb82fa
--- /dev/null
+++ b/codechef/ComplementaryStrandInDna/a.out
Binary files differ
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
new file mode 100755
index 0000000..16c37e0
--- /dev/null
+++ b/codechef/CountSubstrings/main
Binary files differ
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
new file mode 100755
index 0000000..ce92096
--- /dev/null
+++ b/codechef/EquinoxStrings/main
Binary files differ
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
new file mode 100755
index 0000000..7bf6644
--- /dev/null
+++ b/codechef/HiringTest/main
Binary files differ
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
new file mode 100755
index 0000000..4214922
--- /dev/null
+++ b/codechef/Lapindromes/main
Binary files differ
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
new file mode 100755
index 0000000..74a2133
--- /dev/null
+++ b/codechef/Math1Enrolment/main
Binary files differ
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
new file mode 100755
index 0000000..e5ce1f4
--- /dev/null
+++ b/codechef/MaximumWeightDifference/main
Binary files differ
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) {
+ c