diff options
| author | omagdy7 <omar.professional8777@gmail.com> | 2022-06-29 21:03:53 +0200 |
|---|---|---|
| committer | omagdy7 <omar.professional8777@gmail.com> | 2022-06-29 21:03:53 +0200 |
| commit | 37b7e815612dec5655d2ee2363835e2075701ae6 (patch) | |
| tree | 5c0b5e5fcf0c383c0e63c5c86524334630b35139 /codechef/chefAndHisApps | |
| parent | 1b8f7c9d4eb8b767d32dbbbfd96662b73c037627 (diff) | |
| download | competitive-programming-37b7e815612dec5655d2ee2363835e2075701ae6.tar.xz competitive-programming-37b7e815612dec5655d2ee2363835e2075701ae6.zip | |
Solved the first 6 problems of codechef Starters
Diffstat (limited to 'codechef/chefAndHisApps')
| -rw-r--r-- | codechef/chefAndHisApps/inp | 0 | ||||
| -rwxr-xr-x | codechef/chefAndHisApps/main | bin | 0 -> 22624 bytes | |||
| -rw-r--r-- | codechef/chefAndHisApps/main.cpp | 33 | ||||
| -rw-r--r-- | codechef/chefAndHisApps/main_input0.txt | 5 | ||||
| -rw-r--r-- | codechef/chefAndHisApps/main_output0.txt | 4 |
5 files changed, 42 insertions, 0 deletions
diff --git a/codechef/chefAndHisApps/inp b/codechef/chefAndHisApps/inp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/codechef/chefAndHisApps/inp diff --git a/codechef/chefAndHisApps/main b/codechef/chefAndHisApps/main Binary files differnew file mode 100755 index 0000000..5e05251 --- /dev/null +++ b/codechef/chefAndHisApps/main 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 <bits/stdc++.h> + +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 |
