aboutsummaryrefslogtreecommitdiff
path: root/strangeAddition
diff options
context:
space:
mode:
Diffstat (limited to 'strangeAddition')
-rwxr-xr-xstrangeAddition/mainbin0 -> 46808 bytes
-rw-r--r--strangeAddition/main.cpp51
-rw-r--r--strangeAddition/main_input0.txt2
-rw-r--r--strangeAddition/main_input1.txt2
-rw-r--r--strangeAddition/main_output0.txt2
-rw-r--r--strangeAddition/main_output1.txt2
6 files changed, 59 insertions, 0 deletions
diff --git a/strangeAddition/main b/strangeAddition/main
new file mode 100755
index 0000000..32d1277
--- /dev/null
+++ b/strangeAddition/main
Binary files differ
diff --git a/strangeAddition/main.cpp b/strangeAddition/main.cpp
new file mode 100644
index 0000000..4e1e203
--- /dev/null
+++ b/strangeAddition/main.cpp
@@ -0,0 +1,51 @@
+#include <algorithm>
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int n;
+ cin >> n;
+ int zeros = 0;
+ vector<int> ind;
+ vector<int> v(n);
+ for(int i = 0; i < n; i++) {
+ cin >> v[i];
+ int y = v[i];
+ if(v[i] == 0) {
+ zeros++;
+ ind.push_back(i);
+ }
+ while(y >= 1) {
+ int d = y % 10;
+ y /= 10;
+ if(d == 0) {
+ zeros++;
+ ind.push_back(i);
+ break;
+ }
+ }
+ }
+ int diff = 1;
+ zeros = zeros * 2;
+ cout << min(zeros, n) << endl;
+ vector<int> ans;
+ for(int i = 0; i < n; i++) {
+ if(count(ind.begin(), ind.end(), i)) {
+ ans.push_back(v[i]);
+ }
+ }
+ for(int i = 0; i < n; i++){
+ if(!count(ind.begin(), ind.end(), i) && diff) {
+ ans.push_back(v[i]);
+ diff--;
+ }
+ }
+ sort(ans.begin(), ans.end());
+ for(auto x : ans) {
+ cout << x << " ";
+ }
+ cout << endl;
+}
diff --git a/strangeAddition/main_input0.txt b/strangeAddition/main_input0.txt
new file mode 100644
index 0000000..27669ab
--- /dev/null
+++ b/strangeAddition/main_input0.txt
@@ -0,0 +1,2 @@
+4
+100 10 1 0
diff --git a/strangeAddition/main_input1.txt b/strangeAddition/main_input1.txt
new file mode 100644
index 0000000..bd4305b
--- /dev/null
+++ b/strangeAddition/main_input1.txt
@@ -0,0 +1,2 @@
+3
+2 70 3
diff --git a/strangeAddition/main_output0.txt b/strangeAddition/main_output0.txt
new file mode 100644
index 0000000..e9a3643
--- /dev/null
+++ b/strangeAddition/main_output0.txt
@@ -0,0 +1,2 @@
+4
+0 1 10 100
diff --git a/strangeAddition/main_output1.txt b/strangeAddition/main_output1.txt
new file mode 100644
index 0000000..0cd8cd5
--- /dev/null
+++ b/strangeAddition/main_output1.txt
@@ -0,0 +1,2 @@
+2
+2 70