diff options
| author | omagdy7 <omar.professional8777@gmail.com> | 2023-07-27 22:54:30 +0300 |
|---|---|---|
| committer | omagdy7 <omar.professional8777@gmail.com> | 2023-07-27 22:54:30 +0300 |
| commit | 75d27a9d569208041107785353aed66b7a50f091 (patch) | |
| tree | 3173c5f6e4322b7e3b5e11b6042a3a38f98fa164 /codeforces | |
| parent | 41ce2d5446f6f075eb8711fe1ec50b7d0e53e5f4 (diff) | |
| download | competitive-programming-75d27a9d569208041107785353aed66b7a50f091.tar.xz competitive-programming-75d27a9d569208041107785353aed66b7a50f091.zip | |
Solved A, B from today's codeforces edu round
Diffstat (limited to 'codeforces')
| -rwxr-xr-x | codeforces/Monsters/main | bin | 0 -> 42856 bytes | |||
| -rwxr-xr-x | codeforces/Monsters/main.cpp | 145 | ||||
| -rw-r--r-- | codeforces/Monsters/main_input0.txt | 7 | ||||
| -rw-r--r-- | codeforces/Monsters/main_output0.txt | 3 | ||||
| -rwxr-xr-x | codeforces/MorningSandwich/main | bin | 0 -> 20536 bytes | |||
| -rwxr-xr-x | codeforces/MorningSandwich/main.cpp | 162 | ||||
| -rw-r--r-- | codeforces/MorningSandwich/main_input0.txt | 4 | ||||
| -rw-r--r-- | codeforces/MorningSandwich/main_output0.txt | 3 |
8 files changed, 324 insertions, 0 deletions
diff --git a/codeforces/Monsters/main b/codeforces/Monsters/main Binary files differnew file mode 100755 index 0000000..55f3251 --- /dev/null +++ b/codeforces/Monsters/main diff --git a/codeforces/Monsters/main.cpp b/codeforces/Monsters/main.cpp new file mode 100755 index 0000000..efb7382 --- /dev/null +++ b/codeforces/Monsters/main.cpp @@ -0,0 +1,145 @@ +#include <bits/stdc++.h> +using namespace std; + +using ll = long long; +using pii = pair<int, int>; +using vpi = vector<pii>; +using vi = vector<int>; +using vll = vector<long long>; +using mpii = map<int, int>; +using mpll = map<ll, ll>; +using db = long double; + +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound +#define make_unique(x) \ + sort(all((x))); \ + (x).resize(unique(all((x))) - (x).begin()) +#define ceil(a, b) ((a) + (b) - 1) / (b)) + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +template <typename K, typename V> +ostream &operator<<(ostream &os, const pair<K, V> &p); +template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec); +template <typename K, typename V> +ostream &operator<<(ostream &os, const map<K, V> &m); +template <typename K, typename V> +ostream &operator<<(ostream &os, const unordered_map<K, V> &m); +template <typename T> ostream &operator<<(ostream &os, const set<T> &s); +template <typename T> +ostream &operator<<(ostream &os, const unordered_set<T> &s); + +template <typename K, typename V> +ostream &operator<<(ostream &os, const pair<K, V> &p) { + os << "(" << p.first << ", " << p.second << ")"; + return os; +} + +template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { + os << "{"; + for (size_t i = 0; i < vec.size(); ++i) { + if (i > 0) + os << ", "; + os << vec[i]; + } + os << "}"; + return os; +} + +template <typename K, typename V> +ostream &operator<<(ostream &os, const map<K, V> &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template <typename K, typename V> +ostream &operator<<(ostream &os, const unordered_map<K, V> &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template <typename T> ostream &operator<<(ostream &os, const set<T> &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +template <typename T> +ostream &operator<<(ostream &os, const unordered_set<T> &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +void dbg() { cerr << "\n"; } + +template <typename T, typename... TS> void dbg(T val, TS... vals) { + cerr << val << " "; + dbg(vals...); +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ + +void solve() { + int n, k; + cin >> n >> k; + vector<pii> v(n); + for (int i = 0; i < n; i++) { + int x; + cin >> x; + x %= k; + if (x == 0) + x = k; + v[i] = {x, -i}; + } + sort(rall(v)); + for (int i = 0; i < n; i++) { + cout << -v[i].second + 1 << " \n"[i == n - 1]; + } +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/codeforces/Monsters/main_input0.txt b/codeforces/Monsters/main_input0.txt new file mode 100644 index 0000000..f8854bd --- /dev/null +++ b/codeforces/Monsters/main_input0.txt @@ -0,0 +1,7 @@ +3 +3 2 +1 2 3 +2 3 +1 1 +4 3 +2 8 3 5 diff --git a/codeforces/Monsters/main_output0.txt b/codeforces/Monsters/main_output0.txt new file mode 100644 index 0000000..9aee41b --- /dev/null +++ b/codeforces/Monsters/main_output0.txt @@ -0,0 +1,3 @@ +2 1 3 +1 2 +3 1 2 4 diff --git a/codeforces/MorningSandwich/main b/codeforces/MorningSandwich/main Binary files differnew file mode 100755 index 0000000..4d5a32a --- /dev/null +++ b/codeforces/MorningSandwich/main diff --git a/codeforces/MorningSandwich/main.cpp b/codeforces/MorningSandwich/main.cpp new file mode 100755 index 0000000..1e97100 --- /dev/null +++ b/codeforces/MorningSandwich/main.cpp @@ -0,0 +1,162 @@ +#include <bits/stdc++.h> +using namespace std; + +using ll = long long; +using pii = pair<int, int>; +using vpi = vector<pii>; +using vi = vector<int>; +using vll = vector<long long>; +using mpii = map<int, int>; +using mpll = map<ll, ll>; +using db = long double; + +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound +#define make_unique(x) \ + sort(all((x))); \ + (x).resize(unique(all((x))) - (x).begin()) +#define ceil(a, b) ((a) + (b) - 1) / (b)) + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +template <typename K, typename V> +ostream &operator<<(ostream &os, const pair<K, V> &p); +template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec); +template <typename K, typename V> +ostream &operator<<(ostream &os, const map<K, V> &m); +template <typename K, typename V> +ostream &operator<<(ostream &os, const unordered_map<K, V> &m); +template <typename T> ostream &operator<<(ostream &os, const set<T> &s); +template <typename T> +ostream &operator<<(ostream &os, const unordered_set<T> &s); + +template <typename K, typename V> +ostream &operator<<(ostream &os, const pair<K, V> &p) { + os << "(" << p.first << ", " << p.second << ")"; + return os; +} + +template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { + os << "{"; + for (size_t i = 0; i < vec.size(); ++i) { + if (i > 0) + os << ", "; + os << vec[i]; + } + os << "}"; + return os; +} + +template <typename K, typename V> +ostream &operator<<(ostream &os, const map<K, V> &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template <typename K, typename V> +ostream &operator<<(ostream &os, const unordered_map<K, V> &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template <typename T> ostream &operator<<(ostream &os, const set<T> &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +template <typename T> +ostream &operator<<(ostream &os, const unordered_set<T> &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +void dbg() { cerr << "\n"; } + +template <typename T, typename... TS> void dbg(T val, TS... vals) { + cerr << val << " "; + dbg(vals...); +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ + +// b +// f +// b +// f +// b +// f + +void solve() { + int b, c, h; + cin >> b >> c >> h; + int ch = c + h; + int i = 1; + vi v; + while (true) { + if (b == 0 || ch == 0) + break; + if (i % 2 == 0) { + ch--; + v.push_back(0); + } else { + b--; + v.push_back(1); + } + i++; + } + if (ch == 0 && b != 0) { + v.push_back(1); + } + if (v.back() == 0) { + cout << v.size() - 1 << '\n'; + } else { + cout << v.size() << '\n'; + } +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/codeforces/MorningSandwich/main_input0.txt b/codeforces/MorningSandwich/main_input0.txt new file mode 100644 index 0000000..54ba632 --- /dev/null +++ b/codeforces/MorningSandwich/main_input0.txt @@ -0,0 +1,4 @@ +3 +2 1 1 +10 1 2 +3 7 8 diff --git a/codeforces/MorningSandwich/main_output0.txt b/codeforces/MorningSandwich/main_output0.txt new file mode 100644 index 0000000..e7bc618 --- /dev/null +++ b/codeforces/MorningSandwich/main_output0.txt @@ -0,0 +1,3 @@ +3 +7 +5 |
