diff options
| author | omagdy7 <omar.professional8777@gmail.com> | 2023-03-19 11:58:33 +0200 |
|---|---|---|
| committer | omagdy7 <omar.professional8777@gmail.com> | 2023-03-19 11:58:33 +0200 |
| commit | ba391960d9d26180335fccc2f3d593021324de76 (patch) | |
| tree | 7fb520af7ba4ff0b56a2e67282bf8c3f686fb36d /codeforces/CormenTheBestFriendOfAMan | |
| parent | ef09dc1158cfb989a59af5e987d1791d159ad055 (diff) | |
| download | competitive-programming-ba391960d9d26180335fccc2f3d593021324de76.tar.xz competitive-programming-ba391960d9d26180335fccc2f3d593021324de76.zip | |
Solved new problems from codeforces
Diffstat (limited to 'codeforces/CormenTheBestFriendOfAMan')
| -rwxr-xr-x | codeforces/CormenTheBestFriendOfAMan/main | bin | 0 -> 22296 bytes | |||
| -rwxr-xr-x | codeforces/CormenTheBestFriendOfAMan/main.cpp | 17 | ||||
| -rw-r--r-- | codeforces/CormenTheBestFriendOfAMan/main_input0.txt | 2 | ||||
| -rw-r--r-- | codeforces/CormenTheBestFriendOfAMan/main_input1.txt | 2 | ||||
| -rw-r--r-- | codeforces/CormenTheBestFriendOfAMan/main_input2.txt | 2 | ||||
| -rw-r--r-- | codeforces/CormenTheBestFriendOfAMan/main_output0.txt | 2 | ||||
| -rw-r--r-- | codeforces/CormenTheBestFriendOfAMan/main_output1.txt | 2 | ||||
| -rw-r--r-- | codeforces/CormenTheBestFriendOfAMan/main_output2.txt | 2 |
8 files changed, 29 insertions, 0 deletions
diff --git a/codeforces/CormenTheBestFriendOfAMan/main b/codeforces/CormenTheBestFriendOfAMan/main Binary files differnew file mode 100755 index 0000000..43222bb --- /dev/null +++ b/codeforces/CormenTheBestFriendOfAMan/main 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 |
