diff options
| author | omagdy7 <omar.professional8777@gmail.com> | 2022-11-01 11:51:53 +0200 |
|---|---|---|
| committer | omagdy7 <omar.professional8777@gmail.com> | 2022-11-01 11:51:53 +0200 |
| commit | 91ca20b8f78eeeb74fc4eea6eeecdca9fefa5656 (patch) | |
| tree | 0b8fa3a57f5e442c8134f089e64019aba89c5b19 /codechef | |
| parent | f2c878488b659cd19ccecc9880e042251585fdbb (diff) | |
| download | competitive-programming-91ca20b8f78eeeb74fc4eea6eeecdca9fefa5656.tar.xz competitive-programming-91ca20b8f78eeeb74fc4eea6eeecdca9fefa5656.zip | |
Added new problems
Diffstat (limited to 'codechef')
27 files changed, 213 insertions, 0 deletions
diff --git a/codechef/DifferentConsecutiveCharacter/main b/codechef/DifferentConsecutiveCharacter/main Binary files differnew file mode 100755 index 0000000..1469d82 --- /dev/null +++ b/codechef/DifferentConsecutiveCharacter/main diff --git a/codechef/DifferentConsecutiveCharacter/main.cpp b/codechef/DifferentConsecutiveCharacter/main.cpp new file mode 100644 index 0000000..18cc70e --- /dev/null +++ b/codechef/DifferentConsecutiveCharacter/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; + while(tt--){ + int n; + cin >> n; + string s; + cin >> s; + int ans = 0; + for(int i = 0; i < n - 1; i++) { + if(s[i + 1] == s[i]) { + s[i] = s[i + 1] - '0'; + ans++; + } + } + cout << ans << endl; + } +} diff --git a/codechef/DifferentConsecutiveCharacter/main_input0.txt b/codechef/DifferentConsecutiveCharacter/main_input0.txt new file mode 100644 index 0000000..1956197 --- /dev/null +++ b/codechef/DifferentConsecutiveCharacter/main_input0.txt @@ -0,0 +1,7 @@ +3 +2 +11 +4 +0101 +5 +00100 diff --git a/codechef/DifferentConsecutiveCharacter/main_output0.txt b/codechef/DifferentConsecutiveCharacter/main_output0.txt new file mode 100644 index 0000000..56f24a1 --- /dev/null +++ b/codechef/DifferentConsecutiveCharacter/main_output0.txt @@ -0,0 +1,3 @@ +1 +0 +2 diff --git a/codechef/FinalSum/main b/codechef/FinalSum/main Binary files differnew file mode 100755 index 0000000..c385446 --- /dev/null +++ b/codechef/FinalSum/main diff --git a/codechef/FinalSum/main.cpp b/codechef/FinalSum/main.cpp new file mode 100644 index 0000000..4fc98d8 --- /dev/null +++ b/codechef/FinalSum/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, q; + cin >> n >> q; + vector<int> v(n); + for(auto &x : v) { + cin >> x; + } + int k = 0; + while(q--) { + int x, y; + cin >> x >> y; + k += (y - x + 1) % 2; + } + cout << accumulate(v.begin(), v.end(), 0) + k << '\n'; + } +} diff --git a/codechef/FinalSum/main_input0.txt b/codechef/FinalSum/main_input0.txt new file mode 100644 index 0000000..1c11117 --- /dev/null +++ b/codechef/FinalSum/main_input0.txt @@ -0,0 +1,10 @@ +2 +5 3 +1 3 4 4 2 +1 5 +3 4 +2 2 +1 2 +4 +1 1 +1 1 diff --git a/codechef/FinalSum/main_output0.txt b/codechef/FinalSum/main_output0.txt new file mode 100644 index 0000000..ef273a4 --- /dev/null +++ b/codechef/FinalSum/main_output0.txt @@ -0,0 +1,2 @@ +16 +6 diff --git a/codechef/MakeMultiple/main b/codechef/MakeMultiple/main Binary files differnew file mode 100755 index 0000000..06c7ecf --- /dev/null +++ b/codechef/MakeMultiple/main diff --git a/codechef/MakeMultiple/main.cpp b/codechef/MakeMultiple/main.cpp new file mode 100644 index 0000000..653970c --- /dev/null +++ b/codechef/MakeMultiple/main.cpp @@ -0,0 +1,15 @@ +#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 a, b; + cin >> a >> b; + cout << ((a <= b / 2 || a == b) ? "YES" : "NO") << endl; + } +} diff --git a/codechef/MakeMultiple/main_input0.txt b/codechef/MakeMultiple/main_input0.txt new file mode 100644 index 0000000..11784f3 --- /dev/null +++ b/codechef/MakeMultiple/main_input0.txt @@ -0,0 +1,4 @@ +3 +3 6 +4 14 +9 10 diff --git a/codechef/MakeMultiple/main_output0.txt b/codechef/MakeMultiple/main_output0.txt new file mode 100644 index 0000000..5ae1e3d --- /dev/null +++ b/codechef/MakeMultiple/main_output0.txt @@ -0,0 +1,3 @@ +YES +YES +NO diff --git a/codechef/MinimiseLcs/main.cpp b/codechef/MinimiseLcs/main.cpp new file mode 100644 index 0000000..9549f1d --- /dev/null +++ b/codechef/MinimiseLcs/main.cpp @@ -0,0 +1,13 @@ +#include<bits/stdc++.h> + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + + } +} diff --git a/codechef/OddSumPair/main b/codechef/OddSumPair/main Binary files differnew file mode 100755 index 0000000..2579f03 --- /dev/null +++ b/codechef/OddSumPair/main diff --git a/codechef/OddSumPair/main.cpp b/codechef/OddSumPair/main.cpp new file mode 100644 index 0000000..174d714 --- /dev/null +++ b/codechef/OddSumPair/main.cpp @@ -0,0 +1,16 @@ +#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 a, b, c; + cin >> a >> b >> c; + int sum = (a & 1) + (b & 1) + (c & 1); + cout << (sum == 1 || sum == 2 ? "YES" : "NO") << endl; + } +} diff --git a/codechef/OddSumPair/main_input0.txt b/codechef/OddSumPair/main_input0.txt new file mode 100644 index 0000000..b45ce37 --- /dev/null +++ b/codechef/OddSumPair/main_input0.txt @@ -0,0 +1,5 @@ +4 +1 2 3 +8 4 6 +3 3 9 +7 8 6 diff --git a/codechef/OddSumPair/main_output0.txt b/codechef/OddSumPair/main_output0.txt new file mode 100644 index 0000000..c8cd351 --- /dev/null +++ b/codechef/OddSumPair/main_output0.txt @@ -0,0 +1,4 @@ +YES +NO +NO +YES diff --git a/codechef/ReachOnTime/main.cpp b/codechef/ReachOnTime/main.cpp new file mode 100644 index 0000000..caf16c8 --- /dev/null +++ b/codechef/ReachOnTime/main.cpp @@ -0,0 +1,15 @@ +#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 x; + cin >> x; + cout << (x >= 30 ? "YES" : "NO") << endl; + } +} diff --git a/codechef/Rectangle/main b/codechef/Rectangle/main Binary files differnew file mode 100755 index 0000000..e52d0f8 --- /dev/null +++ b/codechef/Rectangle/main diff --git a/codechef/Rectangle/main.cpp b/codechef/Rectangle/main.cpp new file mode 100644 index 0000000..a032542 --- /dev/null +++ b/codechef/Rectangle/main.cpp @@ -0,0 +1,15 @@ +#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 a, b, c, d; + cin >> a >> b >> c >> d; + cout << ((a ^ b ^ c ^ d) == 0 ? "YES" : "NO") << endl; + } +} diff --git a/codechef/Rectangle/main_input0.txt b/codechef/Rectangle/main_input0.txt new file mode 100644 index 0000000..3a34a60 --- /dev/null +++ b/codechef/Rectangle/main_input0.txt @@ -0,0 +1,4 @@ +3 +1 1 2 2 +3 2 2 3 +1 2 2 2 diff --git a/codechef/Rectangle/main_output0.txt b/codechef/Rectangle/main_output0.txt new file mode 100644 index 0000000..5ae1e3d --- /dev/null +++ b/codechef/Rectangle/main_output0.txt @@ -0,0 +1,3 @@ +YES +YES +NO diff --git a/codechef/ShortestPathInBinaryTrees/main b/codechef/ShortestPathInBinaryTrees/main Binary files differnew file mode 100755 index 0000000..1b29c37 --- /dev/null +++ b/codechef/ShortestPathInBinaryTrees/main diff --git a/codechef/ShortestPathInBinaryTrees/main.cpp b/codechef/ShortestPathInBinaryTrees/main.cpp new file mode 100644 index 0000000..eb5f641 --- /dev/null +++ b/codechef/ShortestPathInBinaryTrees/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; + while(tt--){ + int i, j; + cin >> i >> j; + int ans = 0; + while(i != j) { + if (j > i) { + j /= 2; + } else { + i /= 2; + } + ans++; + } + cout << ans << '\n'; + } +} diff --git a/codechef/ShortestPathInBinaryTrees/main_input0.txt b/codechef/ShortestPathInBinaryTrees/main_input0.txt new file mode 100644 index 0000000..94da79c --- /dev/null +++ b/codechef/ShortestPathInBinaryTrees/main_input0.txt @@ -0,0 +1,4 @@ +3 +1 2 +2 3 +4 3 diff --git a/codechef/ShortestPathInBinaryTrees/main_output0.txt b/codechef/ShortestPathInBinaryTrees/main_output0.txt new file mode 100644 index 0000000..01e79c3 --- /dev/null +++ b/codechef/ShortestPathInBinaryTrees/main_output0.txt @@ -0,0 +1,3 @@ +1 +2 +3 diff --git a/codechef/chopSticks/main.cpp b/codechef/chopSticks/main.cpp new file mode 100644 index 0000000..5f6862e --- /dev/null +++ b/codechef/chopSticks/main.cpp @@ -0,0 +1,14 @@ +#include<bits/stdc++.h> + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + + + } +} |
