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/RetriveTheArray | |
| 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/RetriveTheArray')
| -rw-r--r-- | codechef/RetriveTheArray/inp | 0 | ||||
| -rwxr-xr-x | codechef/RetriveTheArray/main | bin | 0 -> 27480 bytes | |||
| -rw-r--r-- | codechef/RetriveTheArray/main.cpp | 28 | ||||
| -rw-r--r-- | codechef/RetriveTheArray/main_input0.txt | 9 | ||||
| -rw-r--r-- | codechef/RetriveTheArray/main_output0.txt | 4 |
5 files changed, 41 insertions, 0 deletions
diff --git a/codechef/RetriveTheArray/inp b/codechef/RetriveTheArray/inp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/codechef/RetriveTheArray/inp diff --git a/codechef/RetriveTheArray/main b/codechef/RetriveTheArray/main Binary files differnew file mode 100755 index 0000000..c45f726 --- /dev/null +++ b/codechef/RetriveTheArray/main diff --git a/codechef/RetriveTheArray/main.cpp b/codechef/RetriveTheArray/main.cpp new file mode 100644 index 0000000..491e6db --- /dev/null +++ b/codechef/RetriveTheArray/main.cpp @@ -0,0 +1,28 @@ +#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<long long> v(n); + long long sum = 0; + for(auto &x : v){ + cin >> x; + sum += x; + } + vector<long long> ans(n); + for(int i = 0; i < n; i++) { + ans[i] = v[i] - sum / (n + 1); + } + for(auto x : ans) { + cout << x << " "; + } + cout << endl; + } +} diff --git a/codechef/RetriveTheArray/main_input0.txt b/codechef/RetriveTheArray/main_input0.txt new file mode 100644 index 0000000..bfebcbe --- /dev/null +++ b/codechef/RetriveTheArray/main_input0.txt @@ -0,0 +1,9 @@ +4 +1 +6 +3 +7 8 9 +4 +13 15 13 14 +2 +25 20 diff --git a/codechef/RetriveTheArray/main_output0.txt b/codechef/RetriveTheArray/main_output0.txt new file mode 100644 index 0000000..3110f5d --- /dev/null +++ b/codechef/RetriveTheArray/main_output0.txt @@ -0,0 +1,4 @@ +3 +1 2 3 +2 4 2 3 +10 5 |
