From ba391960d9d26180335fccc2f3d593021324de76 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Sun, 19 Mar 2023 11:58:33 +0200 Subject: Solved new problems from codeforces --- codeforces/CormenTheBestFriendOfAMan/main | Bin 0 -> 22296 bytes codeforces/CormenTheBestFriendOfAMan/main.cpp | 17 +++++++++++++++++ codeforces/CormenTheBestFriendOfAMan/main_input0.txt | 2 ++ codeforces/CormenTheBestFriendOfAMan/main_input1.txt | 2 ++ codeforces/CormenTheBestFriendOfAMan/main_input2.txt | 2 ++ codeforces/CormenTheBestFriendOfAMan/main_output0.txt | 2 ++ codeforces/CormenTheBestFriendOfAMan/main_output1.txt | 2 ++ codeforces/CormenTheBestFriendOfAMan/main_output2.txt | 2 ++ 8 files changed, 29 insertions(+) create mode 100755 codeforces/CormenTheBestFriendOfAMan/main create mode 100644 codeforces/CormenTheBestFriendOfAMan/main_input0.txt create mode 100644 codeforces/CormenTheBestFriendOfAMan/main_input1.txt create mode 100644 codeforces/CormenTheBestFriendOfAMan/main_input2.txt create mode 100644 codeforces/CormenTheBestFriendOfAMan/main_output0.txt create mode 100644 codeforces/CormenTheBestFriendOfAMan/main_output1.txt create mode 100644 codeforces/CormenTheBestFriendOfAMan/main_output2.txt (limited to 'codeforces/CormenTheBestFriendOfAMan') diff --git a/codeforces/CormenTheBestFriendOfAMan/main b/codeforces/CormenTheBestFriendOfAMan/main new file mode 100755 index 0000000..43222bb Binary files /dev/null and b/codeforces/CormenTheBestFriendOfAMan/main 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 -- cgit v1.2.3