aboutsummaryrefslogtreecommitdiff
path: root/codeforces/CormenTheBestFriendOfAMan
diff options
context:
space:
mode:
Diffstat (limited to 'codeforces/CormenTheBestFriendOfAMan')
-rwxr-xr-xcodeforces/CormenTheBestFriendOfAMan/mainbin0 -> 22296 bytes
-rwxr-xr-xcodeforces/CormenTheBestFriendOfAMan/main.cpp17
-rw-r--r--codeforces/CormenTheBestFriendOfAMan/main_input0.txt2
-rw-r--r--codeforces/CormenTheBestFriendOfAMan/main_input1.txt2
-rw-r--r--codeforces/CormenTheBestFriendOfAMan/main_input2.txt2
-rw-r--r--codeforces/CormenTheBestFriendOfAMan/main_output0.txt2
-rw-r--r--codeforces/CormenTheBestFriendOfAMan/main_output1.txt2
-rw-r--r--codeforces/CormenTheBestFriendOfAMan/main_output2.txt2
8 files changed, 29 insertions, 0 deletions
diff --git a/codeforces/CormenTheBestFriendOfAMan/main b/codeforces/CormenTheBestFriendOfAMan/main
new file mode 100755
index 0000000..43222bb
--- /dev/null
+++ b/codeforces/CormenTheBestFriendOfAMan/main
Binary files differ
diff --git a/codeforces/CormenTheBestFriendOfAMan/main.cpp b/codeforces/CormenTheBestFriendOfAMan/main.cpp
index 25db2b2..4e41dad 100755
--- a/codeforces/CormenTheBestFriendOfAMan/main.cpp
+++ b/codeforces/CormenTheBestFriendOfAMan/main.cpp
@@ -22,10 +22,27 @@ const db PI = acos((db)-1);
const int dx[4]{1, 0, -1, 0};
const int dy[4]{0, 1, 0, -1};
+// v[i + 1] + v[i] = k
+
void solve() {
int n, k;
cin >> n >> k;
vi v(n);
+ for (auto &x : v) cin >> x;
+ vi ans(n);
+ int cnt = 0;
+ for (int i = 0; i < n - 1; i++) {
+ if (v[i] + v[i + 1] < k) {
+ int aw = k - v[i];
+ cnt += aw - v[i + 1];
+ v[i + 1] = aw;
+ }
+ }
+ cout << cnt << '\n';
+ for (auto x : v) {
+ cout << x << ' ';
+ }
+ cout << '\n';
}
diff --git a/codeforces/CormenTheBestFriendOfAMan/main_input0.txt b/codeforces/CormenTheBestFriendOfAMan/main_input0.txt
new file mode 100644
index 0000000..6642156
--- /dev/null
+++ b/codeforces/CormenTheBestFriendOfAMan/main_input0.txt
@@ -0,0 +1,2 @@
+3 5
+2 0 1
diff --git a/codeforces/CormenTheBestFriendOfAMan/main_input1.txt b/codeforces/CormenTheBestFriendOfAMan/main_input1.txt
new file mode 100644
index 0000000..2e3b056
--- /dev/null
+++ b/codeforces/CormenTheBestFriendOfAMan/main_input1.txt
@@ -0,0 +1,2 @@
+3 1
+0 0 0
diff --git a/codeforces/CormenTheBestFriendOfAMan/main_input2.txt b/codeforces/CormenTheBestFriendOfAMan/main_input2.txt
new file mode 100644
index 0000000..d0085cf
--- /dev/null
+++ b/codeforces/CormenTheBestFriendOfAMan/main_input2.txt
@@ -0,0 +1,2 @@
+4 6
+2 4 3 5
diff --git a/codeforces/CormenTheBestFriendOfAMan/main_output0.txt b/codeforces/CormenTheBestFriendOfAMan/main_output0.txt
new file mode 100644
index 0000000..0639b2b
--- /dev/null
+++ b/codeforces/CormenTheBestFriendOfAMan/main_output0.txt
@@ -0,0 +1,2 @@
+4
+2 3 2
diff --git a/codeforces/CormenTheBestFriendOfAMan/main_output1.txt b/codeforces/CormenTheBestFriendOfAMan/main_output1.txt
new file mode 100644
index 0000000..4fd2a3f
--- /dev/null
+++ b/codeforces/CormenTheBestFriendOfAMan/main_output1.txt
@@ -0,0 +1,2 @@
+1
+0 1 0
diff --git a/codeforces/CormenTheBestFriendOfAMan/main_output2.txt b/codeforces/CormenTheBestFriendOfAMan/main_output2.txt
new file mode 100644
index 0000000..9b66e1b
--- /dev/null
+++ b/codeforces/CormenTheBestFriendOfAMan/main_output2.txt
@@ -0,0 +1,2 @@
+0
+2 4 3 5