From ef09dc1158cfb989a59af5e987d1791d159ad055 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Mon, 13 Mar 2023 12:59:41 +0200 Subject: Solved some problems --- codechef/NameReduction/main | Bin 0 -> 17544 bytes codechef/NameReduction/main.cpp | 89 ++++++++++++++ codechef/NameReduction/main_input0.txt | 12 ++ codechef/NameReduction/main_output0.txt | 3 + codeforces/SettlementOfGuineaPigs/main | Bin 0 -> 17488 bytes codeforces/SettlementOfGuineaPigs/main.cpp | 33 ++++++ codeforces/SettlementOfGuineaPigs/main_input0.txt | 13 ++ codeforces/SettlementOfGuineaPigs/main_output0.txt | 6 + contests/NeviusWelcomeRound(div1+div2)/A/main | Bin 0 -> 17928 bytes contests/NeviusWelcomeRound(div1+div2)/A/main.cpp | 106 +++++++++++++++++ .../A/main_input0.txt | 6 + .../A/main_output0.txt | 5 + contests/NeviusWelcomeRound(div1+div2)/B/main | Bin 0 -> 22896 bytes contests/NeviusWelcomeRound(div1+div2)/B/main.cpp | 105 ++++++++++++++++ .../B/main_input0.txt | 11 ++ .../B/main_output0.txt | 5 + contests/NeviusWelcomeRound(div1+div2)/C/main.cpp | 91 ++++++++++++++ contests/NeviusWelcomeRound(div1+div2)/D/main.cpp | 91 ++++++++++++++ contests/NeviusWelcomeRound(div1+div2)/E/main.cpp | 91 ++++++++++++++ contests/NeviusWelcomeRound(div1+div2)/F/main.cpp | 91 ++++++++++++++ contests/Round#857/A/main | Bin 0 -> 42968 bytes contests/Round#857/A/main.cpp | 121 +++++++++++++++++++ contests/Round#857/A/main_input0.txt | 11 ++ contests/Round#857/A/main_input1.txt | 3 + contests/Round#857/A/main_output0.txt | 10 ++ contests/Round#857/A/main_output1.txt | 2 + contests/Round#857/B/main | Bin 0 -> 17336 bytes contests/Round#857/B/main.cpp | 132 +++++++++++++++++++++ contests/Round#857/B/main_input0.txt | 13 ++ contests/Round#857/B/main_output0.txt | 6 + contests/Round#857/C/main.cpp | 89 ++++++++++++++ contests/Round#857/D/main.cpp | 89 ++++++++++++++ contests/Round#857/E/main.cpp | 89 ++++++++++++++ contests/Round#857/F/main.cpp | 89 ++++++++++++++ contests/Starters80/A/main | Bin 0 -> 17736 bytes contests/Starters80/A/main.cpp | 98 +++++++++++++++ contests/Starters80/A/main_input0.txt | 5 + contests/Starters80/A/main_output0.txt | 4 + contests/Starters80/B/main | Bin 0 -> 22528 bytes contests/Starters80/B/main.cpp | 102 ++++++++++++++++ contests/Starters80/B/main_input0.txt | 13 ++ contests/Starters80/B/main_output0.txt | 4 + contests/Starters80/C/main | Bin 0 -> 23000 bytes contests/Starters80/C/main.cpp | 101 ++++++++++++++++ contests/Starters80/C/main_input0.txt | 7 ++ contests/Starters80/C/main_output0.txt | 3 + contests/Starters80/D/main | Bin 0 -> 33800 bytes contests/Starters80/D/main.cpp | 125 +++++++++++++++++++ contests/Starters80/D/main_input0.txt | 4 + contests/Starters80/D/main_input1.txt | 2 + contests/Starters80/D/main_input2.txt | 2 + contests/Starters80/D/main_input3.txt | 2 + contests/Starters80/D/main_input4.txt | 2 + contests/Starters80/D/main_output0.txt | 3 + contests/Starters80/D/main_output1.txt | 1 + contests/Starters80/D/main_output2.txt | 1 + contests/Starters80/D/main_output3.txt | 1 + contests/Starters80/D/main_output4.txt | 1 + contests/Starters80/E/main | Bin 0 -> 61424 bytes contests/Starters80/E/main.cpp | 110 +++++++++++++++++ contests/Starters80/E/main_input0.txt | 5 + contests/Starters80/E/main_output0.txt | 2 + contests/Starters80/F/main.cpp | 89 ++++++++++++++ contests/Starters80/main.cpp | 0 contests/Starters80/main_input0.txt | 5 + contests/Starters80/main_output0.txt | 2 + contests/testcont/A/main.cpp | 13 -- contests/testcont/B/main.cpp | 13 -- contests/testcont/C/main.cpp | 13 -- contests/testcont/D/main.cpp | 13 -- contests/testcont/E/main.cpp | 13 -- contests/testcont/F/main.cpp | 13 -- cses/DynamicProgramming/BookShop/main | Bin 0 -> 17544 bytes cses/DynamicProgramming/BookShop/main.cpp | 89 ++++++++++++++ cses/DynamicProgramming/BookShop/main_input0.txt | 3 + cses/DynamicProgramming/BookShop/main_output0.txt | 1 + cses/SortingAndSearching/Apartments/main | Bin 63000 -> 17200 bytes cses/SortingAndSearching/Apartments/main.cpp | 18 +-- 78 files changed, 2200 insertions(+), 95 deletions(-) create mode 100755 codechef/NameReduction/main create mode 100755 codechef/NameReduction/main.cpp create mode 100644 codechef/NameReduction/main_input0.txt create mode 100644 codechef/NameReduction/main_output0.txt create mode 100755 codeforces/SettlementOfGuineaPigs/main create mode 100755 codeforces/SettlementOfGuineaPigs/main.cpp create mode 100644 codeforces/SettlementOfGuineaPigs/main_input0.txt create mode 100644 codeforces/SettlementOfGuineaPigs/main_output0.txt create mode 100755 contests/NeviusWelcomeRound(div1+div2)/A/main create mode 100755 contests/NeviusWelcomeRound(div1+div2)/A/main.cpp create mode 100644 contests/NeviusWelcomeRound(div1+div2)/A/main_input0.txt create mode 100644 contests/NeviusWelcomeRound(div1+div2)/A/main_output0.txt create mode 100755 contests/NeviusWelcomeRound(div1+div2)/B/main create mode 100755 contests/NeviusWelcomeRound(div1+div2)/B/main.cpp create mode 100644 contests/NeviusWelcomeRound(div1+div2)/B/main_input0.txt create mode 100644 contests/NeviusWelcomeRound(div1+div2)/B/main_output0.txt create mode 100755 contests/NeviusWelcomeRound(div1+div2)/C/main.cpp create mode 100755 contests/NeviusWelcomeRound(div1+div2)/D/main.cpp create mode 100755 contests/NeviusWelcomeRound(div1+div2)/E/main.cpp create mode 100755 contests/NeviusWelcomeRound(div1+div2)/F/main.cpp create mode 100755 contests/Round#857/A/main create mode 100755 contests/Round#857/A/main.cpp create mode 100644 contests/Round#857/A/main_input0.txt create mode 100644 contests/Round#857/A/main_input1.txt create mode 100644 contests/Round#857/A/main_output0.txt create mode 100644 contests/Round#857/A/main_output1.txt create mode 100755 contests/Round#857/B/main create mode 100755 contests/Round#857/B/main.cpp create mode 100644 contests/Round#857/B/main_input0.txt create mode 100644 contests/Round#857/B/main_output0.txt create mode 100755 contests/Round#857/C/main.cpp create mode 100755 contests/Round#857/D/main.cpp create mode 100755 contests/Round#857/E/main.cpp create mode 100755 contests/Round#857/F/main.cpp create mode 100755 contests/Starters80/A/main create mode 100755 contests/Starters80/A/main.cpp create mode 100644 contests/Starters80/A/main_input0.txt create mode 100644 contests/Starters80/A/main_output0.txt create mode 100755 contests/Starters80/B/main create mode 100755 contests/Starters80/B/main.cpp create mode 100644 contests/Starters80/B/main_input0.txt create mode 100644 contests/Starters80/B/main_output0.txt create mode 100755 contests/Starters80/C/main create mode 100755 contests/Starters80/C/main.cpp create mode 100644 contests/Starters80/C/main_input0.txt create mode 100644 contests/Starters80/C/main_output0.txt create mode 100755 contests/Starters80/D/main create mode 100755 contests/Starters80/D/main.cpp create mode 100644 contests/Starters80/D/main_input0.txt create mode 100644 contests/Starters80/D/main_input1.txt create mode 100644 contests/Starters80/D/main_input2.txt create mode 100644 contests/Starters80/D/main_input3.txt create mode 100644 contests/Starters80/D/main_input4.txt create mode 100644 contests/Starters80/D/main_output0.txt create mode 100644 contests/Starters80/D/main_output1.txt create mode 100644 contests/Starters80/D/main_output2.txt create mode 100644 contests/Starters80/D/main_output3.txt create mode 100644 contests/Starters80/D/main_output4.txt create mode 100755 contests/Starters80/E/main create mode 100755 contests/Starters80/E/main.cpp create mode 100644 contests/Starters80/E/main_input0.txt create mode 100644 contests/Starters80/E/main_output0.txt create mode 100755 contests/Starters80/F/main.cpp create mode 100644 contests/Starters80/main.cpp create mode 100644 contests/Starters80/main_input0.txt create mode 100644 contests/Starters80/main_output0.txt delete mode 100755 contests/testcont/A/main.cpp delete mode 100755 contests/testcont/B/main.cpp delete mode 100755 contests/testcont/C/main.cpp delete mode 100755 contests/testcont/D/main.cpp delete mode 100755 contests/testcont/E/main.cpp delete mode 100755 contests/testcont/F/main.cpp create mode 100755 cses/DynamicProgramming/BookShop/main create mode 100755 cses/DynamicProgramming/BookShop/main.cpp create mode 100644 cses/DynamicProgramming/BookShop/main_input0.txt create mode 100644 cses/DynamicProgramming/BookShop/main_output0.txt diff --git a/codechef/NameReduction/main b/codechef/NameReduction/main new file mode 100755 index 0000000..ba80a62 Binary files /dev/null and b/codechef/NameReduction/main differ diff --git a/codechef/NameReduction/main.cpp b/codechef/NameReduction/main.cpp new file mode 100755 index 0000000..7590c13 --- /dev/null +++ b/codechef/NameReduction/main.cpp @@ -0,0 +1,89 @@ +#include +using namespace std; + +using ll = long long; +using pi = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +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 + +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}; + +//pretty printing +template +void printm(const map &mp) { + cerr << "{" << endl; + for (auto p : mp) { + cerr << " { " << p.first << " : " << p.second << " }\n"; + } + cerr << "}" << endl; +} +template +void printv(const vector &v) { + cerr << "["; + for (int i = 0; i < v.size(); i++) { + if (i == v.size() - 1) { + cerr << v[i]; + } else { + cerr << v[i] << ", "; + } + } + cerr << "]\n"; +} + +template +void printvv(const vector> &v) { + cerr << "[\n"; + for (auto &vec : v) { + cout << " "; + printv(vec); + } + cerr << "]\n"; +} +void print() { + cerr << "\n"; +} + +template +void print(T val, TS... vals) { + cerr << val << " "; + print(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 main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + + diff --git a/codechef/NameReduction/main_input0.txt b/codechef/NameReduction/main_input0.txt new file mode 100644 index 0000000..531226a --- /dev/null +++ b/codechef/NameReduction/main_input0.txt @@ -0,0 +1,12 @@ +3 +tom marvoloriddle +2 +lord +voldemort +cheap up +1 +heapcup +bruce wayne +2 +bat +man diff --git a/codechef/NameReduction/main_output0.txt b/codechef/NameReduction/main_output0.txt new file mode 100644 index 0000000..5ae1e3d --- /dev/null +++ b/codechef/NameReduction/main_output0.txt @@ -0,0 +1,3 @@ +YES +YES +NO diff --git a/codeforces/SettlementOfGuineaPigs/main b/codeforces/SettlementOfGuineaPigs/main new file mode 100755 index 0000000..f500644 Binary files /dev/null and b/codeforces/SettlementOfGuineaPigs/main differ diff --git a/codeforces/SettlementOfGuineaPigs/main.cpp b/codeforces/SettlementOfGuineaPigs/main.cpp new file mode 100755 index 0000000..95d9ee5 --- /dev/null +++ b/codeforces/SettlementOfGuineaPigs/main.cpp @@ -0,0 +1,33 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + int n; + cin >> n; + int cur = 0; + int pigs = 0; + int ans = 0; + auto get = [&](int x) { + return x == 0 ? 0 : (1 + x / 2); + }; + for (int i = 0; i < n; i++) { + int x; + cin >> x; + if (x == 1) { + pigs += 1; + } else { + ans = max(ans, get(cur) + pigs); + cur += pigs; + pigs = 0; + } + } + ans = max(ans, get(cur) + pigs); + cout << ans << '\n'; + } +} diff --git a/codeforces/SettlementOfGuineaPigs/main_input0.txt b/codeforces/SettlementOfGuineaPigs/main_input0.txt new file mode 100644 index 0000000..d60568c --- /dev/null +++ b/codeforces/SettlementOfGuineaPigs/main_input0.txt @@ -0,0 +1,13 @@ +6 +3 +1 1 1 +3 +2 2 2 +5 +1 1 1 2 1 +10 +1 2 1 2 1 2 1 2 1 2 +20 +1 2 1 1 1 1 1 2 1 2 1 2 2 1 1 1 1 1 1 1 +20 +2 1 1 2 1 1 2 1 2 2 1 1 1 2 2 1 1 1 1 2 diff --git a/codeforces/SettlementOfGuineaPigs/main_output0.txt b/codeforces/SettlementOfGuineaPigs/main_output0.txt new file mode 100644 index 0000000..ea5c498 --- /dev/null +++ b/codeforces/SettlementOfGuineaPigs/main_output0.txt @@ -0,0 +1,6 @@ +3 +0 +3 +4 +12 +9 diff --git a/contests/NeviusWelcomeRound(div1+div2)/A/main b/contests/NeviusWelcomeRound(div1+div2)/A/main new file mode 100755 index 0000000..2ab498b Binary files /dev/null and b/contests/NeviusWelcomeRound(div1+div2)/A/main differ diff --git a/contests/NeviusWelcomeRound(div1+div2)/A/main.cpp b/contests/NeviusWelcomeRound(div1+div2)/A/main.cpp new file mode 100755 index 0000000..a54c436 --- /dev/null +++ b/contests/NeviusWelcomeRound(div1+div2)/A/main.cpp @@ -0,0 +1,106 @@ +#include +using namespace std; + +using ll = long long; +using pii = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +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 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}; + +//pretty printing +template +void printm(const map &mp) { + cerr << "{" << endl; + for (auto p : mp) { + cerr << " { " << p.first << " : " << p.second << " }\n"; + } + cerr << "}" << endl; +} +template +void printv(const vector &v) { + cerr << "["; + for (int i = 0; i < v.size(); i++) { + if (i == v.size() - 1) { + cerr << v[i]; + } else { + cerr << v[i] << ", "; + } + } + cerr << "]\n"; +} + +template +void printvv(const vector> &v) { + cerr << "[\n"; + for (auto &vec : v) { + cout << " "; + printv(vec); + } + cerr << "]\n"; +} +void print() { + cerr << "\n"; +} + +template +void print(T val, TS... vals) { + cerr << val << " "; + print(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 a, b; + cin >> a >> b; + a = abs(a); + b = abs(b); + ll ans = 0; + if (a > b || a < b) { + int tmp = min(a, b); + int mx = max(a, b); + print(tmp); + ans += tmp * 2; + ans += (mx - tmp) * 2 - 1; + cout << ans << '\n'; + } else { + cout << abs(a) * 2 << '\n'; + } + +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + + diff --git a/contests/NeviusWelcomeRound(div1+div2)/A/main_input0.txt b/contests/NeviusWelcomeRound(div1+div2)/A/main_input0.txt new file mode 100644 index 0000000..c45dff2 --- /dev/null +++ b/contests/NeviusWelcomeRound(div1+div2)/A/main_input0.txt @@ -0,0 +1,6 @@ +5 +-4 1 +4 4 +0 -6 +-5 -4 +7 -8 diff --git a/contests/NeviusWelcomeRound(div1+div2)/A/main_output0.txt b/contests/NeviusWelcomeRound(div1+div2)/A/main_output0.txt new file mode 100644 index 0000000..9637260 --- /dev/null +++ b/contests/NeviusWelcomeRound(div1+div2)/A/main_output0.txt @@ -0,0 +1,5 @@ +7 +8 +11 +9 +15 diff --git a/contests/NeviusWelcomeRound(div1+div2)/B/main b/contests/NeviusWelcomeRound(div1+div2)/B/main new file mode 100755 index 0000000..7ff53f1 Binary files /dev/null and b/contests/NeviusWelcomeRound(div1+div2)/B/main differ diff --git a/contests/NeviusWelcomeRound(div1+div2)/B/main.cpp b/contests/NeviusWelcomeRound(div1+div2)/B/main.cpp new file mode 100755 index 0000000..1ed836d --- /dev/null +++ b/contests/NeviusWelcomeRound(div1+div2)/B/main.cpp @@ -0,0 +1,105 @@ +#include +using namespace std; + + +using ll = long long; +using pii = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +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 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}; + +//pretty printing +template +void printm(const map &mp) { + cerr << "{" << endl; + for (auto p : mp) { + cerr << " { " << p.first << " : " << p.second << " }\n"; + } + cerr << "}" << endl; +} +template +void printv(const vector &v) { + cerr << "["; + for (int i = 0; i < v.size(); i++) { + if (i == v.size() - 1) { + cerr << v[i]; + } else { + cerr << v[i] << ", "; + } + } + cerr << "]\n"; +} + +template +void printvv(const vector> &v) { + cerr << "[\n"; + for (auto &vec : v) { + cout << " "; + printv(vec); + } + cerr << "]\n"; +} +void print() { + cerr << "\n"; +} + +template +void print(T val, TS... vals) { + cerr << val << " "; + print(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, d, w; + cin >> n >> k >> d >> w; + vi v(n); + int ans = 1; + for (auto &x : v) cin >> x; + pii p = make_pair(v[0], 0); + for (int i = 1; i < n; i++) { + if (v[i] - p.first - w > d || i - p.second >= k) { + ans++; + p.first = v[i]; + p.second = i; + } + } + cout << ans << '\n'; +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + + diff --git a/contests/NeviusWelcomeRound(div1+div2)/B/main_input0.txt b/contests/NeviusWelcomeRound(div1+div2)/B/main_input0.txt new file mode 100644 index 0000000..6b9dff9 --- /dev/null +++ b/contests/NeviusWelcomeRound(div1+div2)/B/main_input0.txt @@ -0,0 +1,11 @@ +5 +6 3 5 3 +1 2 3 10 11 18 +6 4 0 0 +3 3 3 3 3 4 +9 10 2 2 +0 1 2 3 4 5 6 7 8 +3 10 3 6 +10 20 30 +5 5 4 4 +0 2 4 6 8 diff --git a/contests/NeviusWelcomeRound(div1+div2)/B/main_output0.txt b/contests/NeviusWelcomeRound(div1+div2)/B/main_output0.txt new file mode 100644 index 0000000..dd56969 --- /dev/null +++ b/contests/NeviusWelcomeRound(div1+div2)/B/main_output0.txt @@ -0,0 +1,5 @@ +2 +3 +2 +3 +1 diff --git a/contests/NeviusWelcomeRound(div1+div2)/C/main.cpp b/contests/NeviusWelcomeRound(div1+div2)/C/main.cpp new file mode 100755 index 0000000..9af49f8 --- /dev/null +++ b/contests/NeviusWelcomeRound(div1+div2)/C/main.cpp @@ -0,0 +1,91 @@ +#include +using namespace std; + +using ll = long long; +using pii = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +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 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}; + +//pretty printing +template +void printm(const map &mp) { + cerr << "{" << endl; + for (auto p : mp) { + cerr << " { " << p.first << " : " << p.second << " }\n"; + } + cerr << "}" << endl; +} +template +void printv(const vector &v) { + cerr << "["; + for (int i = 0; i < v.size(); i++) { + if (i == v.size() - 1) { + cerr << v[i]; + } else { + cerr << v[i] << ", "; + } + } + cerr << "]\n"; +} + +template +void printvv(const vector> &v) { + cerr << "[\n"; + for (auto &vec : v) { + cout << " "; + printv(vec); + } + cerr << "]\n"; +} +void print() { + cerr << "\n"; +} + +template +void print(T val, TS... vals) { + cerr << val << " "; + print(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 main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + + diff --git a/contests/NeviusWelcomeRound(div1+div2)/D/main.cpp b/contests/NeviusWelcomeRound(div1+div2)/D/main.cpp new file mode 100755 index 0000000..9af49f8 --- /dev/null +++ b/contests/NeviusWelcomeRound(div1+div2)/D/main.cpp @@ -0,0 +1,91 @@ +#include +using namespace std; + +using ll = long long; +using pii = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +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 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}; + +//pretty printing +template +void printm(const map &mp) { + cerr << "{" << endl; + for (auto p : mp) { + cerr << " { " << p.first << " : " << p.second << " }\n"; + } + cerr << "}" << endl; +} +template +void printv(const vector &v) { + cerr << "["; + for (int i = 0; i < v.size(); i++) { + if (i == v.size() - 1) { + cerr << v[i]; + } else { + cerr << v[i] << ", "; + } + } + cerr << "]\n"; +} + +template +void printvv(const vector> &v) { + cerr << "[\n"; + for (auto &vec : v) { + cout << " "; + printv(vec); + } + cerr << "]\n"; +} +void print() { + cerr << "\n"; +} + +template +void print(T val, TS... vals) { + cerr << val << " "; + print(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 main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + + diff --git a/contests/NeviusWelcomeRound(div1+div2)/E/main.cpp b/contests/NeviusWelcomeRound(div1+div2)/E/main.cpp new file mode 100755 index 0000000..9af49f8 --- /dev/null +++ b/contests/NeviusWelcomeRound(div1+div2)/E/main.cpp @@ -0,0 +1,91 @@ +#include +using namespace std; + +using ll = long long; +using pii = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +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 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}; + +//pretty printing +template +void printm(const map &mp) { + cerr << "{" << endl; + for (auto p : mp) { + cerr << " { " << p.first << " : " << p.second << " }\n"; + } + cerr << "}" << endl; +} +template +void printv(const vector &v) { + cerr << "["; + for (int i = 0; i < v.size(); i++) { + if (i == v.size() - 1) { + cerr << v[i]; + } else { + cerr << v[i] << ", "; + } + } + cerr << "]\n"; +} + +template +void printvv(const vector> &v) { + cerr << "[\n"; + for (auto &vec : v) { + cout << " "; + printv(vec); + } + cerr << "]\n"; +} +void print() { + cerr << "\n"; +} + +template +void print(T val, TS... vals) { + cerr << val << " "; + print(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 main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + + diff --git a/contests/NeviusWelcomeRound(div1+div2)/F/main.cpp b/contests/NeviusWelcomeRound(div1+div2)/F/main.cpp new file mode 100755 index 0000000..9af49f8 --- /dev/null +++ b/contests/NeviusWelcomeRound(div1+div2)/F/main.cpp @@ -0,0 +1,91 @@ +#include +using namespace std; + +using ll = long long; +using pii = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +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 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}; + +//pretty printing +template +void printm(const map &mp) { + cerr << "{" << endl; + for (auto p : mp) { + cerr << " { " << p.first << " : " << p.second << " }\n"; + } + cerr << "}" << endl; +} +template +void printv(const vector &v) { + cerr << "["; + for (int i = 0; i < v.size(); i++) { + if (i == v.size() - 1) { + cerr << v[i]; + } else { + cerr << v[i] << ", "; + } + } + cerr << "]\n"; +} + +template +void printvv(const vector> &v) { + cerr << "[\n"; + for (auto &vec : v) { + cout << " "; + printv(vec); + } + cerr << "]\n"; +} +void print() { + cerr << "\n"; +} + +template +void print(T val, TS... vals) { + cerr << val << " "; + print(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 main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + + diff --git a/contests/Round#857/A/main b/contests/Round#857/A/main new file mode 100755 index 0000000..162e13a Binary files /dev/null and b/contests/Round#857/A/main differ diff --git a/contests/Round#857/A/main.cpp b/contests/Round#857/A/main.cpp new file mode 100755 index 0000000..baecf5a --- /dev/null +++ b/contests/Round#857/A/main.cpp @@ -0,0 +1,121 @@ +#include +using namespace std; + +using ll = long long; +using pi = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +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 + +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}; + +//pretty printing +template +void printm(const map &mp) { + cerr << "{" << endl; + for (auto p : mp) { + cerr << " { " << p.first << " : " << p.second << " }\n"; + } + cerr << "}" << endl; +} +template +void printv(const vector &v) { + cerr << "["; + for (int i = 0; i < v.size(); i++) { + if (i == v.size() - 1) { + cerr << v[i]; + } else { + cerr << v[i] << ", "; + } + } + cerr << "]\n"; +} + +template +void printvv(const vector> &v) { + cerr << "[\n"; + for (auto &vec : v) { + cout << " "; + printv(vec); + } + cerr << "]\n"; +} +void print() { + cerr << "\n"; +} + +template +void print(T val, TS... vals) { + cerr << val << " "; + print(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; + cin >> n; + vi v(n); + int neg = 0; + for (int i = 0; i < n; i++) { + int x; + cin >> x; + v[i] = x; + neg += x < 0; + } + sort(rall(v)); + int pos = 1; + for (int i = 0; i < n; i++) { + if (v[i] > 0) { + cout << pos << ' '; + pos++; + } else { + pos--; + cout << pos - 1 << ' '; + } + } + cout << '\n'; + for (int i = 0; i < neg; i++) { + cout << 1 << ' ' << 0 << ' '; + } + for (int i = 0; i < n - neg * 2; i++) { + cout << i + 1 << ' '; + } + cout << '\n'; + + + + +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + + diff --git a/contests/Round#857/A/main_input0.txt b/contests/Round#857/A/main_input0.txt new file mode 100644 index 0000000..edc0583 --- /dev/null +++ b/contests/Round#857/A/main_input0.txt @@ -0,0 +1,11 @@ +5 +3 +1 2 -2 +2 +1 -1 +6 +4 3 -1 2 1 -2 +5 +4 2 -2 1 3 +7 +-1 6 -4 3 2 4 1 diff --git a/contests/Round#857/A/main_input1.txt b/contests/Round#857/A/main_input1.txt new file mode 100644 index 0000000..f439e9e --- /dev/null +++ b/contests/Round#857/A/main_input1.txt @@ -0,0 +1,3 @@ +1 +8 +1 -1 1 -1 1 -1 1 -1 \ No newline at end of file diff --git a/contests/Round#857/A/main_output0.txt b/contests/Round#857/A/main_output0.txt new file mode 100644 index 0000000..d947087 --- /dev/null +++ b/contests/Round#857/A/main_output0.txt @@ -0,0 +1,10 @@ +1 2 1 +1 0 1 +1 0 +1 0 +1 2 3 4 3 2 +1 0 1 0 1 2 +1 2 3 4 3 +1 0 1 2 3 +1 2 3 4 5 4 3 +1 0 1 0 1 2 3 diff --git a/contests/Round#857/A/main_output1.txt b/contests/Round#857/A/main_output1.txt new file mode 100644 index 0000000..5ba3329 --- /dev/null +++ b/contests/Round#857/A/main_output1.txt @@ -0,0 +1,2 @@ +1 2 3 4 3 2 1 0 +1 0 1 0 1 0 1 0 \ No newline at end of file diff --git a/contests/Round#857/B/main b/contests/Round#857/B/main new file mode 100755 index 0000000..fa8f5c5 Binary files /dev/null and b/contests/Round#857/B/main differ diff --git a/contests/Round#857/B/main.cpp b/contests/Round#857/B/main.cpp new file mode 100755 index 0000000..324c05c --- /dev/null +++ b/contests/Round#857/B/main.cpp @@ -0,0 +1,132 @@ +#include +using namespace std; + +using ll = long long; +using pi = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +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 + +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}; + +//pretty printing +template +void printm(const map &mp) { + cerr << "{" << endl; + for (auto p : mp) { + cerr << " { " << p.first << " : " << p.second << " }\n"; + } + cerr << "}" << endl; +} +template +void printv(const vector &v) { + cerr << "["; + for (int i = 0; i < v.size(); i++) { + if (i == v.size() - 1) { + cerr << v[i]; + } else { + cerr << v[i] << ", "; + } + } + cerr << "]\n"; +} + +template +void printvv(const vector> &v) { + cerr << "[\n"; + for (auto &vec : v) { + cout << " "; + printv(vec); + } + cerr << "]\n"; +} +void print() { + cerr << "\n"; +} + +template +void print(T val, TS... vals) { + cerr << val << " "; + print(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 + */ + +vi helper(vi &v) { + vi ret; + v.pb(2); + int x = 0; + for (int i = 0; i < v.size(); i++) { + if (v[i] == 1) { + x++; + } else { + if (x != 0) { + ret.pb(x); + } + x = 0; + } + } + return ret; +} + +// 10 2 3 4 +// max(1 + 10 / 2 + 2, 10) +// max(1 + 12 / 2 + 3, 10) +// max(1 + 15 / 2 + 4, 10) +// max(1 + 15 / 2 + 4, 11) + +void solve() { + int n; + uint32_t x; + cin >> n; + vi v(n); + for (auto &x : v) cin >> x; + vi tmp = v; + vi ret = helper(tmp); + if(ret.size() == 0) { + cout << 0 << '\n'; + return; + } + int pfx = ret[0]; + int ans = ret[0]; + for (int i = 1; i < ret.size(); i++) { + if (ret[i] == 0) continue; + ans = max(1 + pfx / 2 + ret[i], ans); + pfx += ret[i]; + } + cout << ans << '\n'; + +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + + diff --git a/contests/Round#857/B/main_input0.txt b/contests/Round#857/B/main_input0.txt new file mode 100644 index 0000000..d60568c --- /dev/null +++ b/contests/Round#857/B/main_input0.txt @@ -0,0 +1,13 @@ +6 +3 +1 1 1 +3 +2 2 2 +5 +1 1 1 2 1 +10 +1 2 1 2 1 2 1 2 1 2 +20 +1 2 1 1 1 1 1 2 1 2 1 2 2 1 1 1 1 1 1 1 +20 +2 1 1 2 1 1 2 1 2 2 1 1 1 2 2 1 1 1 1 2 diff --git a/contests/Round#857/B/main_output0.txt b/contests/Round#857/B/main_output0.txt new file mode 100644 index 0000000..ea5c498 --- /dev/null +++ b/contests/Round#857/B/main_output0.txt @@ -0,0 +1,6 @@ +3 +0 +3 +4 +12 +9 diff --git a/contests/Round#857/C/main.cpp b/contests/Round#857/C/main.cpp new file mode 100755 index 0000000..7590c13 --- /dev/null +++ b/contests/Round#857/C/main.cpp @@ -0,0 +1,89 @@ +#include +using namespace std; + +using ll = long long; +using pi = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +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 + +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}; + +//pretty printing +template +void printm(const map &mp) { + cerr << "{" << endl; + for (auto p : mp) { + cerr << " { " << p.first << " : " << p.second << " }\n"; + } + cerr << "}" << endl; +} +template +void printv(const vector &v) { + cerr << "["; + for (int i = 0; i < v.size(); i++) { + if (i == v.size() - 1) { + cerr << v[i]; + } else { + cerr << v[i] << ", "; + } + } + cerr << "]\n"; +} + +template +void printvv(const vector> &v) { + cerr << "[\n"; + for (auto &vec : v) { + cout << " "; + printv(vec); + } + cerr << "]\n"; +} +void print() { + cerr << "\n"; +} + +template +void print(T val, TS... vals) { + cerr << val << " "; + print(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 main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + + diff --git a/contests/Round#857/D/main.cpp b/contests/Round#857/D/main.cpp new file mode 100755 index 0000000..7590c13 --- /dev/null +++ b/contests/Round#857/D/main.cpp @@ -0,0 +1,89 @@ +#include +using namespace std; + +using ll = long long; +using pi = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +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 + +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}; + +//pretty printing +template +void printm(const map &mp) { + cerr << "{" << endl; + for (auto p : mp) { + cerr << " { " << p.first << " : " << p.second << " }\n"; + } + cerr << "}" << endl; +} +template +void printv(const vector &v) { + cerr << "["; + for (int i = 0; i < v.size(); i++) { + if (i == v.size() - 1) { + cerr << v[i]; + } else { + cerr << v[i] << ", "; + } + } + cerr << "]\n"; +} + +template +void printvv(const vector> &v) { + cerr << "[\n"; + for (auto &vec : v) { + cout << " "; + printv(vec); + } + cerr << "]\n"; +} +void print() { + cerr << "\n"; +} + +template +void print(T val, TS... vals) { + cerr << val << " "; + print(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 main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + + diff --git a/contests/Round#857/E/main.cpp b/contests/Round#857/E/main.cpp new file mode 100755 index 0000000..7590c13 --- /dev/null +++ b/contests/Round#857/E/main.cpp @@ -0,0 +1,89 @@ +#include +using namespace std; + +using ll = long long; +using pi = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +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 + +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}; + +//pretty printing +template +void printm(const map &mp) { + cerr << "{" << endl; + for (auto p : mp) { + cerr << " { " << p.first << " : " << p.second << " }\n"; + } + cerr << "}" << endl; +} +template +void printv(const vector &v) { + cerr << "["; + for (int i = 0; i < v.size(); i++) { + if (i == v.size() - 1) { + cerr << v[i]; + } else { + cerr << v[i] << ", "; + } + } + cerr << "]\n"; +} + +template +void printvv(const vector> &v) { + cerr << "[\n"; + for (auto &vec : v) { + cout << " "; + printv(vec); + } + cerr << "]\n"; +} +void print() { + cerr << "\n"; +} + +template +void print(T val, TS... vals) { + cerr << val << " "; + print(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 main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + + diff --git a/contests/Round#857/F/main.cpp b/contests/Round#857/F/main.cpp new file mode 100755 index 0000000..7590c13 --- /dev/null +++ b/contests/Round#857/F/main.cpp @@ -0,0 +1,89 @@ +#include +using namespace std; + +using ll = long long; +using pi = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +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 + +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}; + +//pretty printing +template +void printm(const map &mp) { + cerr << "{" << endl; + for (auto p : mp) { + cerr << " { " << p.first << " : " << p.second << " }\n"; + } + cerr << "}" << endl; +} +template +void printv(const vector &v) { + cerr << "["; + for (int i = 0; i < v.size(); i++) { + if (i == v.size() - 1) { + cerr << v[i]; + } else { + cerr << v[i] << ", "; + } + } + cerr << "]\n"; +} + +template +void printvv(const vector> &v) { + cerr << "[\n"; + for (auto &vec : v) { + cout << " "; + printv(vec); + } + cerr << "]\n"; +} +void print() { + cerr << "\n"; +} + +template +void print(T val, TS... vals) { + cerr << val << " "; + print(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 main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + + diff --git a/contests/Starters80/A/main b/contests/Starters80/A/main new file mode 100755 index 0000000..afab9ce Binary files /dev/null and b/contests/Starters80/A/main differ diff --git a/contests/Starters80/A/main.cpp b/contests/Starters80/A/main.cpp new file mode 100755 index 0000000..30e5948 --- /dev/null +++ b/contests/Starters80/A/main.cpp @@ -0,0 +1,98 @@ +#include +using namespace std; + +using ll = long long; +using pi = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +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 + +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}; + +//pretty printing +template +void printm(const map &mp) { + cerr << "{" << endl; + for (auto p : mp) { + cerr << " { " << p.first << " : " << p.second << " }\n"; + } + cerr << "}" << endl; +} +template +void printv(const vector &v) { + cerr << "["; + for (int i = 0; i < v.size(); i++) { + if (i == v.size() - 1) { + cerr << v[i]; + } else { + cerr << v[i] << ", "; + } + } + cerr << "]\n"; +} + +template +void printvv(const vector> &v) { + cerr << "[\n"; + for (auto &vec : v) { + cout << " "; + printv(vec); + } + cerr << "]\n"; +} +void print() { + cerr << "\n"; +} + +template +void print(T val, TS... vals) { + cerr << val << " "; + print(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 h, x, y; + cin >> h >> x >> y; + int ans = 1; + h -= y; + while (h > 0) { + h -= x; + ans++; + } + cout << ans << '\n'; + +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + + diff --git a/contests/Starters80/A/main_input0.txt b/contests/Starters80/A/main_input0.txt new file mode 100644 index 0000000..ed3ba77 --- /dev/null +++ b/contests/Starters80/A/main_input0.txt @@ -0,0 +1,5 @@ +4 +100 25 40 +100 29 45 +46 1 2 +78 15 78 diff --git a/contests/Starters80/A/main_output0.txt b/contests/Starters80/A/main_output0.txt new file mode 100644 index 0000000..ced7f8b --- /dev/null +++ b/contests/Starters80/A/main_output0.txt @@ -0,0 +1,4 @@ +4 +3 +45 +1 diff --git a/contests/Starters80/B/main b/contests/Starters80/B/main new file mode 100755 index 0000000..acb6894 Binary files /dev/null and b/contests/Starters80/B/main differ diff --git a/contests/Starters80/B/main.cpp b/contests/Starters80/B/main.cpp new file mode 100755 index 0000000..eec794e --- /dev/null +++ b/contests/Starters80/B/main.cpp @@ -0,0 +1,102 @@ +#include +using namespace std; + +using ll = long long; +using pi = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +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 + +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}; + +//pretty printing +template +void printm(const map &mp) { + cerr << "{" << endl; + for (auto p : mp) { + cerr << " { " << p.first << " : " << p.second << " }\n"; + } + cerr << "}" << endl; +} +template +void printv(const vector &v) { + cerr << "["; + for (int i = 0; i < v.size(); i++) { + if (i == v.size() - 1) { + cerr << v[i]; + } else { + cerr << v[i] << ", "; + } + } + cerr << "]\n"; +} + +template +void printvv(const vector> &v) { + cerr << "[\n"; + for (auto &vec : v) { + cout << " "; + printv(vec); + } + cerr << "]\n"; +} +void print() { + cerr << "\n"; +} + +template +void print(T val, TS... vals) { + cerr << val << " "; + print(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; + cin >> n; + vi a(n); + vi b(n); + for (auto &x : a) cin >> x; + for (auto &x : b) cin >> x; + int ans = 0; + for (int i = 0; i < n; i++) { + if (abs(a[i] - b[i]) <= max(a[i], b[i]) / 2) { + ans++; + } + } + cout << ans << '\n'; + +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + + diff --git a/contests/Starters80/B/main_input0.txt b/contests/Starters80/B/main_input0.txt new file mode 100644 index 0000000..d772d54 --- /dev/null +++ b/contests/Starters80/B/main_input0.txt @@ -0,0 +1,13 @@ +4 +3 +100 200 300 +300 200 100 +4 +1000 1000 1000 1000 +400 500 600 1200 +4 +800 399 1400 532 +2053 2300 3400 23 +5 +800 850 900 950 1000 +600 800 1000 1200 1400 diff --git a/contests/Starters80/B/main_output0.txt b/contests/Starters80/B/main_output0.txt new file mode 100644 index 0000000..e69337e --- /dev/null +++ b/contests/Starters80/B/main_output0.txt @@ -0,0 +1,4 @@ +1 +3 +0 +5 diff --git a/contests/Starters80/C/main b/contests/Starters80/C/main new file mode 100755 index 0000000..358edd7 Binary files /dev/null and b/contests/Starters80/C/main differ diff --git a/contests/Starters80/C/main.cpp b/contests/Starters80/C/main.cpp new file mode 100755 index 0000000..2dd3ce4 --- /dev/null +++ b/contests/Starters80/C/main.cpp @@ -0,0 +1,101 @@ +#include +using namespace std; + +using ll = long long; +using pi = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +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 + +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}; + +//pretty printing +template +void printm(const map &mp) { + cerr << "{" << endl; + for (auto p : mp) { + cerr << " { " << p.first << " : " << p.second << " }\n"; + } + cerr << "}" << endl; +} +template +void printv(const vector &v) { + cerr << "["; + for (int i = 0; i < v.size(); i++) { + if (i == v.size() - 1) { + cerr << v[i]; + } else { + cerr << v[i] << ", "; + } + } + cerr << "]\n"; +} + +template +void printvv(const vector> &v) { + cerr << "[\n"; + for (auto &vec : v) { + cout << " "; + printv(vec); + } + cerr << "]\n"; +} +void print() { + cerr << "\n"; +} + +template +void print(T val, TS... vals) { + cerr << val << " "; + print(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; + cin >> n; + vi v(n); + vi fq(n); + for (int i = 0; i < n; i++) { + int x; + cin >> x; + v[i] = x; + fq[x]++; + } + int mx = *max_element(all(fq)); + cout << n - mx << '\n'; + +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + + diff --git a/contests/Starters80/C/main_input0.txt b/contests/Starters80/C/main_input0.txt new file mode 100644 index 0000000..a301148 --- /dev/null +++ b/contests/Starters80/C/main_input0.txt @@ -0,0 +1,7 @@ +3 +3 +1 2 3 +4 +2 2 3 1 +4 +3 1 2 4 diff --git a/contests/Starters80/C/main_output0.txt b/contests/Starters80/C/main_output0.txt new file mode 100644 index 0000000..179d8a7 --- /dev/null +++ b/contests/Starters80/C/main_output0.txt @@ -0,0 +1,3 @@ +2 +2 +3 diff --git a/contests/Starters80/D/main b/contests/Starters80/D/main new file mode 100755 index 0000000..52eeeea Binary files /dev/null and b/contests/Starters80/D/main differ diff --git a/contests/Starters80/D/main.cpp b/contests/Starters80/D/main.cpp new file mode 100755 index 0000000..e742d6a --- /dev/null +++ b/contests/Starters80/D/main.cpp @@ -0,0 +1,125 @@ +#include +using namespace std; + +using ll = long long; +using pi = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +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 + +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}; + +//pretty printing +template +void printm(const map &mp) { + cerr << "{" << endl; + for (auto p : mp) { + cerr << " { " << p.first << " : " << p.second << " }\n"; + } + cerr << "}" << endl; +} +template +void printv(const vector &v) { + cerr << "["; + for (int i = 0; i < v.size(); i++) { + if (i == v.size() - 1) { + cerr << v[i]; + } else { + cerr << v[i] << ", "; + } + } + cerr << "]\n"; +} + +template +void printvv(const vector> &v) { + cerr << "[\n"; + for (auto &vec : v) { + cout << " "; + printv(vec); + } + cerr << "]\n"; +} +void print() { + cerr << "\n"; +} + +template +void print(T val, TS... vals) { + cerr << val << " "; + print(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() { + ll n; + cin >> n; + ll sum = (n * (n + 1)) / 2; + vi v1 = {3, 4, 1, 2}; + vi v2 = {1, 2, 4, 6, 3, 5}; + if (sum % n == 0) { + cout << -1 << '\n'; + } else { + vi ans(n); + if (n == 2) { + cout << 1 << " " << 2 << '\n'; + } + else if (n == 4) { + for (auto x : v1) { + cout << x << ' '; + } + cout << '\n'; + } else if (n == 6) { + for (auto x : v2) { + cout << x << ' '; + } + cout << '\n'; + } else { + for (int i = 7; i <= n; i++) { + if (i % 2 == 1) { + v2.push_back(i + 1); + } else { + v2.push_back(i - 1); + } + } + for (auto x : v2) { + cout << x << ' '; + } + cout << '\n'; + } + } + +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + + diff --git a/contests/Starters80/D/main_input0.txt b/contests/Starters80/D/main_input0.txt new file mode 100644 index 0000000..11f6059 --- /dev/null +++ b/contests/Starters80/D/main_input0.txt @@ -0,0 +1,4 @@ +3 +4 +6 +7 diff --git a/contests/Starters80/D/main_input1.txt b/contests/Starters80/D/main_input1.txt new file mode 100644 index 0000000..4551b90 --- /dev/null +++ b/contests/Starters80/D/main_input1.txt @@ -0,0 +1,2 @@ +1 +8 \ No newline at end of file diff --git a/contests/Starters80/D/main_input2.txt b/contests/Starters80/D/main_input2.txt new file mode 100644 index 0000000..ecf8935 --- /dev/null +++ b/contests/Starters80/D/main_input2.txt @@ -0,0 +1,2 @@ +1 +12 \ No newline at end of file diff --git a/contests/Starters80/D/main_input3.txt b/contests/Starters80/D/main_input3.txt new file mode 100644 index 0000000..7a754f4 --- /dev/null +++ b/contests/Starters80/D/main_input3.txt @@ -0,0 +1,2 @@ +1 +2 \ No newline at end of file diff --git a/contests/Starters80/D/main_input4.txt b/contests/Starters80/D/main_input4.txt new file mode 100644 index 0000000..7a754f4 --- /dev/null +++ b/contests/Starters80/D/main_input4.txt @@ -0,0 +1,2 @@ +1 +2 \ No newline at end of file diff --git a/contests/Starters80/D/main_output0.txt b/contests/Starters80/D/main_output0.txt new file mode 100644 index 0000000..5602f68 --- /dev/null +++ b/contests/Starters80/D/main_output0.txt @@ -0,0 +1,3 @@ +3 4 1 2 +1 2 4 6 3 5 +-1 diff --git a/contests/Starters80/D/main_output1.txt b/contests/Starters80/D/main_output1.txt new file mode 100644 index 0000000..f2036c1 --- /dev/null +++ b/contests/Starters80/D/main_output1.txt @@ -0,0 +1 @@ +1 2 4 6 3 5 8 7 \ No newline at end of file diff --git a/contests/Starters80/D/main_output2.txt b/contests/Starters80/D/main_output2.txt new file mode 100644 index 0000000..9a0233d --- /dev/null +++ b/contests/Starters80/D/main_output2.txt @@ -0,0 +1 @@ +1 2 4 6 3 5 8 7 10 9 12 11 \ No newline at end of file diff --git a/contests/Starters80/D/main_output3.txt b/contests/Starters80/D/main_output3.txt new file mode 100644 index 0000000..1c6ae71 --- /dev/null +++ b/contests/Starters80/D/main_output3.txt @@ -0,0 +1 @@ +1 2 \ No newline at end of file diff --git a/contests/Starters80/D/main_output4.txt b/contests/Starters80/D/main_output4.txt new file mode 100644 index 0000000..1c6ae71 --- /dev/null +++ b/contests/Starters80/D/main_output4.txt @@ -0,0 +1 @@ +1 2 \ No newline at end of file diff --git a/contests/Starters80/E/main b/contests/Starters80/E/main new file mode 100755 index 0000000..6f8e448 Binary files /dev/null and b/contests/Starters80/E/main differ diff --git a/contests/Starters80/E/main.cpp b/contests/Starters80/E/main.cpp new file mode 100755 index 0000000..c53ffef --- /dev/null +++ b/contests/Starters80/E/main.cpp @@ -0,0 +1,110 @@ +#include +using namespace std; + +using ll = long long; +using pi = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +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 + +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}; + +//pretty printing +template +void printm(const map &mp) { + cerr << "{" << endl; + for (auto p : mp) { + cerr << " { " << p.first << " : " << p.second << " }\n"; + } + cerr << "}" << endl; +} +template +void printv(const vector &v) { + cerr << "["; + for (int i = 0; i < v.size(); i++) { + if (i == v.size() - 1) { + cerr << v[i]; + } else { + cerr << v[i] << ", "; + } + } + cerr << "]\n"; +} + +template +void printvv(const vector> &v) { + cerr << "[\n"; + for (auto &vec : v) { + cout << " "; + printv(vec); + } + cerr << "]\n"; +} +void print() { + cerr << "\n"; +} + +template +void print(T val, TS... vals) { + cerr << val << " "; + print(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; + cin >> n; + vi v(n); + map fq; + for (int i = 0; i < n; i++) { + int x; + cin >> x; + v[i] = x; + fq[x]++; + } + vll dp(n); + dp[0] = fq[1]; + for (int i = 1; i < n; i++) { + dp[i] = (dp[i - 1] * fq[i + 1]) % MOD; + } + ll sum = 0; + for (auto x : dp) { + sum = (sum + x) % MOD; + } + cout << sum << '\n'; + +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + + diff --git a/contests/Starters80/E/main_input0.txt b/contests/Starters80/E/main_input0.txt new file mode 100644 index 0000000..8353715 --- /dev/null +++ b/contests/Starters80/E/main_input0.txt @@ -0,0 +1,5 @@ +2 +5 +1 2 3 2 4 +6 +1 3 5 8 9 8 diff --git a/contests/Starters80/E/main_output0.txt b/contests/Starters80/E/main_output0.txt new file mode 100644 index 0000000..107b687 --- /dev/null +++ b/contests/Starters80/E/main_output0.txt @@ -0,0 +1,2 @@ +7 +1 diff --git a/contests/Starters80/F/main.cpp b/contests/Starters80/F/main.cpp new file mode 100755 index 0000000..7590c13 --- /dev/null +++ b/contests/Starters80/F/main.cpp @@ -0,0 +1,89 @@ +#include +using namespace std; + +using ll = long long; +using pi = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +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 + +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}; + +//pretty printing +template +void printm(const map &mp) { + cerr << "{" << endl; + for (auto p : mp) { + cerr << " { " << p.first << " : " << p.second << " }\n"; + } + cerr << "}" << endl; +} +template +void printv(const vector &v) { + cerr << "["; + for (int i = 0; i < v.size(); i++) { + if (i == v.size() - 1) { + cerr << v[i]; + } else { + cerr << v[i] << ", "; + } + } + cerr << "]\n"; +} + +template +void printvv(const vector> &v) { + cerr << "[\n"; + for (auto &vec : v) { + cout << " "; + printv(vec); + } + cerr << "]\n"; +} +void print() { + cerr << "\n"; +} + +template +void print(T val, TS... vals) { + cerr << val << " "; + print(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 main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + + diff --git a/contests/Starters80/main.cpp b/contests/Starters80/main.cpp new file mode 100644 index 0000000..e69de29 diff --git a/contests/Starters80/main_input0.txt b/contests/Starters80/main_input0.txt new file mode 100644 index 0000000..8353715 --- /dev/null +++ b/contests/Starters80/main_input0.txt @@ -0,0 +1,5 @@ +2 +5 +1 2 3 2 4 +6 +1 3 5 8 9 8 diff --git a/contests/Starters80/main_output0.txt b/contests/Starters80/main_output0.txt new file mode 100644 index 0000000..107b687 --- /dev/null +++ b/contests/Starters80/main_output0.txt @@ -0,0 +1,2 @@ +7 +1 diff --git a/contests/testcont/A/main.cpp b/contests/testcont/A/main.cpp deleted file mode 100755 index 9549f1d..0000000 --- a/contests/testcont/A/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include - -using namespace std; - -int main () { - ios_base::sync_with_stdio(false); - cin.tie(NULL); - int tt; - cin >> tt; - while(tt--){ - - } -} diff --git a/contests/testcont/B/main.cpp b/contests/testcont/B/main.cpp deleted file mode 100755 index 9549f1d..0000000 --- a/contests/testcont/B/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include - -using namespace std; - -int main () { - ios_base::sync_with_stdio(false); - cin.tie(NULL); - int tt; - cin >> tt; - while(tt--){ - - } -} diff --git a/contests/testcont/C/main.cpp b/contests/testcont/C/main.cpp deleted file mode 100755 index 9549f1d..0000000 --- a/contests/testcont/C/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include - -using namespace std; - -int main () { - ios_base::sync_with_stdio(false); - cin.tie(NULL); - int tt; - cin >> tt; - while(tt--){ - - } -} diff --git a/contests/testcont/D/main.cpp b/contests/testcont/D/main.cpp deleted file mode 100755 index 9549f1d..0000000 --- a/contests/testcont/D/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include - -using namespace std; - -int main () { - ios_base::sync_with_stdio(false); - cin.tie(NULL); - int tt; - cin >> tt; - while(tt--){ - - } -} diff --git a/contests/testcont/E/main.cpp b/contests/testcont/E/main.cpp deleted file mode 100755 index 9549f1d..0000000 --- a/contests/testcont/E/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include - -using namespace std; - -int main () { - ios_base::sync_with_stdio(false); - cin.tie(NULL); - int tt; - cin >> tt; - while(tt--){ - - } -} diff --git a/contests/testcont/F/main.cpp b/contests/testcont/F/main.cpp deleted file mode 100755 index 9549f1d..0000000 --- a/contests/testcont/F/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include - -using namespace std; - -int main () { - ios_base::sync_with_stdio(false); - cin.tie(NULL); - int tt; - cin >> tt; - while(tt--){ - - } -} diff --git a/cses/DynamicProgramming/BookShop/main b/cses/DynamicProgramming/BookShop/main new file mode 100755 index 0000000..ba80a62 Binary f