From 37b7e815612dec5655d2ee2363835e2075701ae6 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Wed, 29 Jun 2022 21:03:53 +0200 Subject: Solved the first 6 problems of codechef Starters --- codechef/chefAndHisApps/inp | 0 codechef/chefAndHisApps/main | Bin 0 -> 22624 bytes codechef/chefAndHisApps/main.cpp | 33 +++++++++++++++++++++++++++++++ codechef/chefAndHisApps/main_input0.txt | 5 +++++ codechef/chefAndHisApps/main_output0.txt | 4 ++++ 5 files changed, 42 insertions(+) create mode 100644 codechef/chefAndHisApps/inp create mode 100755 codechef/chefAndHisApps/main create mode 100644 codechef/chefAndHisApps/main.cpp create mode 100644 codechef/chefAndHisApps/main_input0.txt create mode 100644 codechef/chefAndHisApps/main_output0.txt (limited to 'codechef/chefAndHisApps') diff --git a/codechef/chefAndHisApps/inp b/codechef/chefAndHisApps/inp new file mode 100644 index 0000000..e69de29 diff --git a/codechef/chefAndHisApps/main b/codechef/chefAndHisApps/main new file mode 100755 index 0000000..5e05251 Binary files /dev/null and b/codechef/chefAndHisApps/main differ diff --git a/codechef/chefAndHisApps/main.cpp b/codechef/chefAndHisApps/main.cpp new file mode 100644 index 0000000..8d38e22 --- /dev/null +++ b/codechef/chefAndHisApps/main.cpp @@ -0,0 +1,33 @@ +#include + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + int s, x, y, z; + cin >> s >> x >> y >> z; + int xy = x + y; + int free = s - xy; + int count = 0; + int mx = max(x, y); + // 3 <= 7 + if (z <= free) { + cout << 0 << endl; + } else { + while (z > free) { + z -= max(x, y); + if (x > y) { + x = 0; + } else { + y = 0; + } + count++; + } + cout << count << endl; + } + } +} diff --git a/codechef/chefAndHisApps/main_input0.txt b/codechef/chefAndHisApps/main_input0.txt new file mode 100644 index 0000000..0d4d54e --- /dev/null +++ b/codechef/chefAndHisApps/main_input0.txt @@ -0,0 +1,5 @@ +4 +10 1 2 3 +9 4 5 1 +15 5 10 15 +100 20 30 75 diff --git a/codechef/chefAndHisApps/main_output0.txt b/codechef/chefAndHisApps/main_output0.txt new file mode 100644 index 0000000..93e26d2 --- /dev/null +++ b/codechef/chefAndHisApps/main_output0.txt @@ -0,0 +1,4 @@ +0 +1 +2 +1 -- cgit v1.2.3