diff options
| author | omagdy7 <omar.professional8777@gmail.com> | 2022-07-15 18:34:14 +0200 |
|---|---|---|
| committer | omagdy7 <omar.professional8777@gmail.com> | 2022-07-15 18:34:14 +0200 |
| commit | 51c35987f270f7a19d83a11b2427a9ff7803e17c (patch) | |
| tree | dab8e1690a399b713023a9cdc22ca7ffff86f922 | |
| parent | 0dff824a69c41aea4d4d54017360a368d0c6602f (diff) | |
| download | competitive-programming-51c35987f270f7a19d83a11b2427a9ff7803e17c.tar.xz competitive-programming-51c35987f270f7a19d83a11b2427a9ff7803e17c.zip | |
Solved a couple of problems on codeforces
| -rwxr-xr-x | MarkTheDustSweeper/main | bin | 0 -> 27320 bytes | |||
| -rw-r--r-- | MarkTheDustSweeper/main.cpp | 39 | ||||
| -rw-r--r-- | MarkTheDustSweeper/main_input0.txt | 9 | ||||
| -rw-r--r-- | MarkTheDustSweeper/main_output0.txt | 4 | ||||
| -rwxr-xr-x | MarkThePhotographer/main | bin | 0 -> 44912 bytes | |||
| -rw-r--r-- | MarkThePhotographer/main.cpp | 31 | ||||
| -rw-r--r-- | MarkThePhotographer/main_input0.txt | 7 | ||||
| -rw-r--r-- | MarkThePhotographer/main_output0.txt | 3 | ||||
| -rwxr-xr-x | yapapsai/main | bin | 0 -> 32512 bytes | |||
| -rw-r--r-- | yapapsai/main.cpp | 26 | ||||
| -rw-r--r-- | yapapsai/main_input0.txt | 11 | ||||
| -rw-r--r-- | yapapsai/main_output0.txt | 5 |
12 files changed, 135 insertions, 0 deletions
diff --git a/MarkTheDustSweeper/main b/MarkTheDustSweeper/main Binary files differnew file mode 100755 index 0000000..0ceccde --- /dev/null +++ b/MarkTheDustSweeper/main diff --git a/MarkTheDustSweeper/main.cpp b/MarkTheDustSweeper/main.cpp new file mode 100644 index 0000000..6335886 --- /dev/null +++ b/MarkTheDustSweeper/main.cpp @@ -0,0 +1,39 @@ +#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; + long long ans = 0; + vector<int> v(n); + long long sum = 0; + for (auto &x : v) { + cin >> x; + sum += x; + } + if(sum != v[n - 1]) { + int ind; + for(int i = 0; i < n; i++) { + if(v[i] != 0) { + ind = i; + break; + } + } + for(int i = ind; i < n - 1; i++) { + if(v[i] == 0) { + ans += 1; + } else{ + ans += v[i]; + } + } + } + cout << ans << endl; + } +} diff --git a/MarkTheDustSweeper/main_input0.txt b/MarkTheDustSweeper/main_input0.txt new file mode 100644 index 0000000..ad05cd8 --- /dev/null +++ b/MarkTheDustSweeper/main_input0.txt @@ -0,0 +1,9 @@ +4 +3 +2 0 0 +5 +0 2 0 2 0 +6 +2 0 3 0 4 6 +4 +0 0 0 10 diff --git a/MarkTheDustSweeper/main_output0.txt b/MarkTheDustSweeper/main_output0.txt new file mode 100644 index 0000000..0c8b213 --- /dev/null +++ b/MarkTheDustSweeper/main_output0.txt @@ -0,0 +1,4 @@ +3 +5 +11 +0 diff --git a/MarkThePhotographer/main b/MarkThePhotographer/main Binary files differnew file mode 100755 index 0000000..eaaf214 --- /dev/null +++ b/MarkThePhotographer/main diff --git a/MarkThePhotographer/main.cpp b/MarkThePhotographer/main.cpp new file mode 100644 index 0000000..15c4e29 --- /dev/null +++ b/MarkThePhotographer/main.cpp @@ -0,0 +1,31 @@ +#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, y; + cin >> n >> y; + vector<int> v(2 * n); + int ans = 0; + for (int &x : v) + cin >> x; + sort(v.begin(), v.end()); + for (int i = 0; i < n; i++) { + int x = v[i]; + int z = v[i + n]; + if (z - x >= y) { + ans++; + } + } + if (ans == n) { + cout << "YES" << '\n'; + } else { + cout << "NO" << '\n'; + } + } +} diff --git a/MarkThePhotographer/main_input0.txt b/MarkThePhotographer/main_input0.txt new file mode 100644 index 0000000..3e55cb5 --- /dev/null +++ b/MarkThePhotographer/main_input0.txt @@ -0,0 +1,7 @@ +3 +3 6 +1 3 9 10 12 16 +3 1 +2 5 2 2 2 5 +1 2 +8 6 diff --git a/MarkThePhotographer/main_output0.txt b/MarkThePhotographer/main_output0.txt new file mode 100644 index 0000000..0db7433 --- /dev/null +++ b/MarkThePhotographer/main_output0.txt @@ -0,0 +1,3 @@ +YES +NO +YES diff --git a/yapapsai/main b/yapapsai/main Binary files differnew file mode 100755 index 0000000..a26e653 --- /dev/null +++ b/yapapsai/main diff --git a/yapapsai/main.cpp b/yapapsai/main.cpp new file mode 100644 index 0000000..2946e65 --- /dev/null +++ b/yapapsai/main.cpp @@ -0,0 +1,26 @@ +#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<int> pos; + long long ans = 0; + for (int i = 1; i <= n; i++) { + int x; + cin >> x; + if (x < i) { + auto it = lower_bound(pos.begin(), pos.end(), x); + ans += it - pos.begin(); + pos.emplace_back(i); + } + } + cout << ans << '\n'; + } +} diff --git a/yapapsai/main_input0.txt b/yapapsai/main_input0.txt new file mode 100644 index 0000000..bb1b141 --- /dev/null +++ b/yapapsai/main_input0.txt @@ -0,0 +1,11 @@ +5 +8 +1 1 2 3 8 2 1 4 +2 +1 2 +10 +0 2 1 6 3 4 1 2 8 3 +2 +1 1000000000 +3 +0 1000000000 2 diff --git a/yapapsai/main_output0.txt b/yapapsai/main_output0.txt new file mode 100644 index 0000000..5859aa7 --- /dev/null +++ b/yapapsai/main_output0.txt @@ -0,0 +1,5 @@ +3 +0 +10 +0 +1 |
