diff --git a/codeforces/1049/2140a.cc b/codeforces/1049/2140a.cc new file mode 100644 index 0000000..baa4773 --- /dev/null +++ b/codeforces/1049/2140a.cc @@ -0,0 +1,20 @@ +#include + +using namespace std; + +void solve() { + std::cout << "ho\n"; +} + +int main() { + std::cin.tie(nullptr)->sync_with_stdio(false); + + int tc = 1; + std::cin >> tc; + + for (int t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} diff --git a/codeforces/1049/2140b.cc b/codeforces/1049/2140b.cc new file mode 100644 index 0000000..36eff3c --- /dev/null +++ b/codeforces/1049/2140b.cc @@ -0,0 +1,83 @@ +#include // {{{ + +#include +#ifdef __cpp_lib_ranges_enumerate +#include +namespace rv = std::views; +namespace rs = std::ranges; +#endif + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; + +#if __cplusplus >= 202002L +template constexpr T MIN = std::numeric_limits::min(); + +template constexpr T MAX = std::numeric_limits::max(); + +template [[nodiscard]] static T sc(auto &&x) { + return static_cast(x); +} + +template [[nodiscard]] static T sz(auto &&x) { + return static_cast(x.size()); +} +#endif + +static void NO() { std::cout << "NO\n"; } + +static void YES() { std::cout << "YES\n"; } + +template using vec = std::vector; + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define ff first +#define ss second + +#ifdef LOCAL +#define db(...) std::print(__VA_ARGS__) +#define dbln(...) std::println(__VA_ARGS__) +#else +#define db(...) +#define dbln(...) +#endif +// }}} + +void solve() { + int x; + cout << x << '\n'; +} + +int main() { // {{{ + std::cin.exceptions(std::cin.failbit); + +#ifdef LOCAL + std::cerr.rdbuf(std::cout.rdbuf()); + std::cout.setf(std::ios::unitbuf); + std::cerr.setf(std::ios::unitbuf); +#else + std::cin.tie(nullptr)->sync_with_stdio(false); +#endif + + u32 tc = 1; + std::cin >> tc; + + for (u32 t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/1049/io/2140a.expected b/codeforces/1049/io/2140a.expected new file mode 100644 index 0000000..93e26d2 --- /dev/null +++ b/codeforces/1049/io/2140a.expected @@ -0,0 +1,4 @@ +0 +1 +2 +1 diff --git a/codeforces/1049/io/2140a.in b/codeforces/1049/io/2140a.in new file mode 100644 index 0000000..e3b2e68 --- /dev/null +++ b/codeforces/1049/io/2140a.in @@ -0,0 +1,9 @@ +4 +3 +001 +4 +0110 +6 +110100 +6 +101011 diff --git a/codeforces/1049/io/2140a.out b/codeforces/1049/io/2140a.out new file mode 100644 index 0000000..14a2c5b --- /dev/null +++ b/codeforces/1049/io/2140a.out @@ -0,0 +1,9 @@ +ho +ho +ho +ho + +[code]: 0 +[time]: 2.76 ms +[debug]: false +[matches]: false diff --git a/codeforces/1049/io/2140b.expected b/codeforces/1049/io/2140b.expected new file mode 100644 index 0000000..b7ae5f5 --- /dev/null +++ b/codeforces/1049/io/2140b.expected @@ -0,0 +1,6 @@ +1 +12 +998 +7872 +8190 +174036 diff --git a/codeforces/1049/io/2140b.in b/codeforces/1049/io/2140b.in new file mode 100644 index 0000000..e6bc53b --- /dev/null +++ b/codeforces/1049/io/2140b.in @@ -0,0 +1,7 @@ +6 +8 +42 +1000 +66666 +106344 +9876543 diff --git a/codeforces/1049/io/2140b.out b/codeforces/1049/io/2140b.out new file mode 100644 index 0000000..56ae20c --- /dev/null +++ b/codeforces/1049/io/2140b.out @@ -0,0 +1,11 @@ +0 +0 +0 +0 +0 +0 + +[code]: 0 +[time]: 2.49 ms +[debug]: false +[matches]: false diff --git a/codeforces/1050/2148a.cc b/codeforces/1050/2148a.cc new file mode 100644 index 0000000..6e67e29 --- /dev/null +++ b/codeforces/1050/2148a.cc @@ -0,0 +1,93 @@ +#include // {{{ + +#include +#ifdef __cpp_lib_ranges_enumerate +#include +namespace rv = std::views; +namespace rs = std::ranges; +#endif + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i16 = int16_t; +using u16 = uint16_t; +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; + +#if __cplusplus >= 202002L +template constexpr T MIN = std::numeric_limits::min(); + +template constexpr T MAX = std::numeric_limits::max(); + +template [[nodiscard]] static T sc(auto &&x) { + return static_cast(x); +} + +template [[nodiscard]] static T sz(auto &&x) { + return static_cast(x.size()); +} +#endif + +static void NO() { std::cout << "NO\n"; } + +static void YES() { std::cout << "YES\n"; } + +template using vec = std::vector; + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define ff first +#define ss second + +#ifdef LOCAL +#define db(...) std::print(__VA_ARGS__) +#define dbln(...) std::println(__VA_ARGS__) +#else +#define db(...) +#define dbln(...) +#endif +// }}} + +void solve() { + u16 n, x; + cin >> x >> n; + + if (n & 1) { + cout << x; + } else { + cout << 0; + } + + cout << '\n'; +} + +int main() { // {{{ + std::cin.exceptions(std::cin.failbit); + +#ifdef LOCAL + std::cerr.rdbuf(std::cout.rdbuf()); + std::cout.setf(std::ios::unitbuf); + std::cerr.setf(std::ios::unitbuf); +#else + std::cin.tie(nullptr)->sync_with_stdio(false); +#endif + + u32 tc = 1; + std::cin >> tc; + + for (u32 t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/1050/2148b.cc b/codeforces/1050/2148b.cc new file mode 100644 index 0000000..88a657b --- /dev/null +++ b/codeforces/1050/2148b.cc @@ -0,0 +1,94 @@ +#include // {{{ + +#include +#ifdef __cpp_lib_ranges_enumerate +#include +namespace rv = std::views; +namespace rs = std::ranges; +#endif + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i16 = int16_t; +using u16 = uint16_t; +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; + +#if __cplusplus >= 202002L +template constexpr T MIN = std::numeric_limits::min(); + +template constexpr T MAX = std::numeric_limits::max(); + +template [[nodiscard]] static T sc(auto &&x) { + return static_cast(x); +} + +template [[nodiscard]] static T sz(auto &&x) { + return static_cast(x.size()); +} +#endif + +static void NO() { std::cout << "NO\n"; } + +static void YES() { std::cout << "YES\n"; } + +template using vec = std::vector; + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define ff first +#define ss second + +#ifdef LOCAL +#define db(...) std::print(__VA_ARGS__) +#define dbln(...) std::println(__VA_ARGS__) +#else +#define db(...) +#define dbln(...) +#endif +// }}} + +void solve() { + u32 n, m; + u64 x, y; + cin >> n >> m >> x >> y; + + vec horiz(n), vert(m); + for (auto &e : horiz) + cin >> e; + for (auto &e : vert) + cin >> e; + + println("{}", n + m); +} + +int main() { // {{{ + std::cin.exceptions(std::cin.failbit); + +#ifdef LOCAL + std::cerr.rdbuf(std::cout.rdbuf()); + std::cout.setf(std::ios::unitbuf); + std::cerr.setf(std::ios::unitbuf); +#else + std::cin.tie(nullptr)->sync_with_stdio(false); +#endif + + u32 tc = 1; + std::cin >> tc; + + for (u32 t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/1050/2148c.cc b/codeforces/1050/2148c.cc new file mode 100644 index 0000000..737e9b8 --- /dev/null +++ b/codeforces/1050/2148c.cc @@ -0,0 +1,109 @@ +#include // {{{ + +#include +#ifdef __cpp_lib_ranges_enumerate +#include +namespace rv = std::views; +namespace rs = std::ranges; +#endif + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i16 = int16_t; +using u16 = uint16_t; +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; + +#if __cplusplus >= 202002L +template constexpr T MIN = std::numeric_limits::min(); + +template constexpr T MAX = std::numeric_limits::max(); + +template [[nodiscard]] static T sc(auto &&x) { + return static_cast(x); +} + +template [[nodiscard]] static T sz(auto &&x) { + return static_cast(x.size()); +} +#endif + +static void NO() { std::cout << "NO\n"; } + +static void YES() { std::cout << "YES\n"; } + +template using vec = std::vector; + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define ff first +#define ss second + +#ifdef LOCAL +#define db(...) std::print(__VA_ARGS__) +#define dbln(...) std::println(__VA_ARGS__) +#else +#define db(...) +#define dbln(...) +#endif +// }}} + +void solve() { + u32 n, m; + cin >> n >> m; + + u32 a, b; + + u16 side = 0; + u32 t = 0; + u32 ans = 0; + + for (u32 i = 0; i < n; ++i) { + cin >> a >> b; + + // at time a, must be at side b; was on side side @ time t + + u32 diff = a - t; + ans += diff; + if (diff & 1 && b == side || !(diff & 1) && b != side) { + --ans; + } + t = a; + side = b; + } + + ans += m - t; + + println("{}", ans); +} + +int main() { // {{{ + std::cin.exceptions(std::cin.failbit); + +#ifdef LOCAL + std::cerr.rdbuf(std::cout.rdbuf()); + std::cout.setf(std::ios::unitbuf); + std::cerr.setf(std::ios::unitbuf); +#else + std::cin.tie(nullptr)->sync_with_stdio(false); +#endif + + u32 tc = 1; + std::cin >> tc; + + for (u32 t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/1050/2148d.cc b/codeforces/1050/2148d.cc new file mode 100644 index 0000000..46b1340 --- /dev/null +++ b/codeforces/1050/2148d.cc @@ -0,0 +1,109 @@ +#include // {{{ + +#include +#ifdef __cpp_lib_ranges_enumerate +#include +namespace rv = std::views; +namespace rs = std::ranges; +#endif + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i16 = int16_t; +using u16 = uint16_t; +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; + +#if __cplusplus >= 202002L +template constexpr T MIN = std::numeric_limits::min(); + +template constexpr T MAX = std::numeric_limits::max(); + +template [[nodiscard]] static T sc(auto &&x) { + return static_cast(x); +} + +template [[nodiscard]] static T sz(auto &&x) { + return static_cast(x.size()); +} +#endif + +static void NO() { std::cout << "NO\n"; } + +static void YES() { std::cout << "YES\n"; } + +template using vec = std::vector; + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define ff first +#define ss second + +#ifdef LOCAL +#define db(...) std::print(__VA_ARGS__) +#define dbln(...) std::println(__VA_ARGS__) +#else +#define db(...) +#define dbln(...) +#endif +// }}} + +void solve() { + u32 n, a; + cin >> n; + + vec odd; + u64 even_total = 0, ans = 0; + for (u32 i = 0; i < n; ++i) { + cin >> a; + + if (a & 1) { + odd.push_back(a); + } else { + even_total += a; + } + } + + sort(rall(odd)); + + for (u32 i = 0; i < (odd.size() + 1) / 2; ++i) { + ans += odd[i]; + } + + if (ans > 0) { + ans += even_total; + } + + println("{}", ans); +} + +int main() { // {{{ + std::cin.exceptions(std::cin.failbit); + +#ifdef LOCAL + std::cerr.rdbuf(std::cout.rdbuf()); + std::cout.setf(std::ios::unitbuf); + std::cerr.setf(std::ios::unitbuf); +#else + std::cin.tie(nullptr)->sync_with_stdio(false); +#endif + + u32 tc = 1; + std::cin >> tc; + + for (u32 t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/1050/2148e.cc b/codeforces/1050/2148e.cc new file mode 100644 index 0000000..956965c --- /dev/null +++ b/codeforces/1050/2148e.cc @@ -0,0 +1,112 @@ +#include // {{{ + +#include +#ifdef __cpp_lib_ranges_enumerate +#include +namespace rv = std::views; +namespace rs = std::ranges; +#endif + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i16 = int16_t; +using u16 = uint16_t; +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; + +#if __cplusplus >= 202002L +template constexpr T MIN = std::numeric_limits::min(); + +template constexpr T MAX = std::numeric_limits::max(); + +template [[nodiscard]] static T sc(auto &&x) { + return static_cast(x); +} + +template [[nodiscard]] static T sz(auto &&x) { + return static_cast(x.size()); +} +#endif + +static void NO() { std::cout << "NO\n"; } + +static void YES() { std::cout << "YES\n"; } + +template using vec = std::vector; + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define ff first +#define ss second + +#ifdef LOCAL +#define db(...) std::print(__VA_ARGS__) +#define dbln(...) std::println(__VA_ARGS__) +#else +#define db(...) +#define dbln(...) +#endif +// }}} + +void solve() { + u32 n, k; + cin >> n >> k; + vec a(n); + vec F(n + 1, 0); + for (u32 i = 0; i < n; ++i) { + cin >> a[i]; + ++F[a[i]]; + } + + for (auto &f : F) { + if (f % k) { + println("0"); + return; + } + } + + u64 ans = 0; + map f; + + for (u32 l = 0, r = 0; r < n; ++r) { + ++f[a[r]]; + while (f[a[r]] * k > F[a[r]]) { + --f[a[l]]; + ++l; + } + ans += r - l + 1; + } + + println("{}", ans); +} + +int main() { // {{{ + std::cin.exceptions(std::cin.failbit); + +#ifdef LOCAL + std::cerr.rdbuf(std::cout.rdbuf()); + std::cout.setf(std::ios::unitbuf); + std::cerr.setf(std::ios::unitbuf); +#else + std::cin.tie(nullptr)->sync_with_stdio(false); +#endif + + u32 tc = 1; + std::cin >> tc; + + for (u32 t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/1050/io/2148a.1.cpin b/codeforces/1050/io/2148a.1.cpin new file mode 100644 index 0000000..3b41c94 --- /dev/null +++ b/codeforces/1050/io/2148a.1.cpin @@ -0,0 +1,5 @@ +4 +1 4 +2 5 +3 6 +4 7 diff --git a/codeforces/1050/io/2148a.1.cpout b/codeforces/1050/io/2148a.1.cpout new file mode 100644 index 0000000..33bafbf --- /dev/null +++ b/codeforces/1050/io/2148a.1.cpout @@ -0,0 +1,4 @@ +0 +2 +0 +4 diff --git a/codeforces/1050/io/2148a.cpin b/codeforces/1050/io/2148a.cpin new file mode 100644 index 0000000..3b41c94 --- /dev/null +++ b/codeforces/1050/io/2148a.cpin @@ -0,0 +1,5 @@ +4 +1 4 +2 5 +3 6 +4 7 diff --git a/codeforces/1050/io/2148a.cpout b/codeforces/1050/io/2148a.cpout new file mode 100644 index 0000000..e1b18c3 --- /dev/null +++ b/codeforces/1050/io/2148a.cpout @@ -0,0 +1,9 @@ +0 +2 +0 +4 + +[code]: 0 +[time]: 2.70 ms +[debug]: false +[ok]: true diff --git a/codeforces/1050/io/2148a.expected b/codeforces/1050/io/2148a.expected new file mode 100644 index 0000000..33bafbf --- /dev/null +++ b/codeforces/1050/io/2148a.expected @@ -0,0 +1,4 @@ +0 +2 +0 +4 diff --git a/codeforces/1050/io/2148b.1.cpin b/codeforces/1050/io/2148b.1.cpin new file mode 100644 index 0000000..09d2a07 --- /dev/null +++ b/codeforces/1050/io/2148b.1.cpin @@ -0,0 +1,7 @@ +2 +1 1 2 2 +1 +1 +2 1 100000 100000 +42 58 +32 diff --git a/codeforces/1050/io/2148b.1.cpout b/codeforces/1050/io/2148b.1.cpout new file mode 100644 index 0000000..4792e70 --- /dev/null +++ b/codeforces/1050/io/2148b.1.cpout @@ -0,0 +1,2 @@ +2 +3 diff --git a/codeforces/1050/io/2148b.cpin b/codeforces/1050/io/2148b.cpin new file mode 100644 index 0000000..09d2a07 --- /dev/null +++ b/codeforces/1050/io/2148b.cpin @@ -0,0 +1,7 @@ +2 +1 1 2 2 +1 +1 +2 1 100000 100000 +42 58 +32 diff --git a/codeforces/1050/io/2148b.cpout b/codeforces/1050/io/2148b.cpout new file mode 100644 index 0000000..4346a55 --- /dev/null +++ b/codeforces/1050/io/2148b.cpout @@ -0,0 +1,7 @@ +2 +3 + +[code]: 0 +[time]: 2.45 ms +[debug]: false +[ok]: true diff --git a/codeforces/1050/io/2148b.expected b/codeforces/1050/io/2148b.expected new file mode 100644 index 0000000..4792e70 --- /dev/null +++ b/codeforces/1050/io/2148b.expected @@ -0,0 +1,2 @@ +2 +3 diff --git a/codeforces/1050/io/2148c.1.cpin b/codeforces/1050/io/2148c.1.cpin new file mode 100644 index 0000000..a67fd7c --- /dev/null +++ b/codeforces/1050/io/2148c.1.cpin @@ -0,0 +1,12 @@ +3 +2 4 +2 1 +4 0 +2 7 +1 1 +4 0 +4 9 +1 0 +2 0 +6 1 +9 0 diff --git a/codeforces/1050/io/2148c.1.cpout b/codeforces/1050/io/2148c.1.cpout new file mode 100644 index 0000000..1a969ff --- /dev/null +++ b/codeforces/1050/io/2148c.1.cpout @@ -0,0 +1,3 @@ +2 +7 +6 diff --git a/codeforces/1050/io/2148c.cpin b/codeforces/1050/io/2148c.cpin new file mode 100644 index 0000000..a67fd7c --- /dev/null +++ b/codeforces/1050/io/2148c.cpin @@ -0,0 +1,12 @@ +3 +2 4 +2 1 +4 0 +2 7 +1 1 +4 0 +4 9 +1 0 +2 0 +6 1 +9 0 diff --git a/codeforces/1050/io/2148c.cpout b/codeforces/1050/io/2148c.cpout new file mode 100644 index 0000000..a910fb2 --- /dev/null +++ b/codeforces/1050/io/2148c.cpout @@ -0,0 +1,8 @@ +2 +7 +6 + +[code]: 0 +[time]: 2.88 ms +[debug]: false +[ok]: true diff --git a/codeforces/1050/io/2148c.expected b/codeforces/1050/io/2148c.expected new file mode 100644 index 0000000..1a969ff --- /dev/null +++ b/codeforces/1050/io/2148c.expected @@ -0,0 +1,3 @@ +2 +7 +6 diff --git a/codeforces/1050/io/2148d.1.cpin b/codeforces/1050/io/2148d.1.cpin new file mode 100644 index 0000000..041cea3 --- /dev/null +++ b/codeforces/1050/io/2148d.1.cpin @@ -0,0 +1,7 @@ +3 +3 +2 4 6 +4 +4 2 1 6 +4 +1000000000 999999999 1000000000 999999999 diff --git a/codeforces/1050/io/2148d.1.cpout b/codeforces/1050/io/2148d.1.cpout new file mode 100644 index 0000000..8d57e36 --- /dev/null +++ b/codeforces/1050/io/2148d.1.cpout @@ -0,0 +1,3 @@ +0 +13 +2999999999 diff --git a/codeforces/1050/io/2148d.cpin b/codeforces/1050/io/2148d.cpin new file mode 100644 index 0000000..041cea3 --- /dev/null +++ b/codeforces/1050/io/2148d.cpin @@ -0,0 +1,7 @@ +3 +3 +2 4 6 +4 +4 2 1 6 +4 +1000000000 999999999 1000000000 999999999 diff --git a/codeforces/1050/io/2148d.cpout b/codeforces/1050/io/2148d.cpout new file mode 100644 index 0000000..e54108a --- /dev/null +++ b/codeforces/1050/io/2148d.cpout @@ -0,0 +1,8 @@ +0 +13 +2999999999 + +[code]: 0 +[time]: 2.53 ms +[debug]: false +[ok]: true diff --git a/codeforces/1050/io/2148d.expected b/codeforces/1050/io/2148d.expected new file mode 100644 index 0000000..8d57e36 --- /dev/null +++ b/codeforces/1050/io/2148d.expected @@ -0,0 +1,3 @@ +0 +13 +2999999999 diff --git a/codeforces/1050/io/2148e.1.cpin b/codeforces/1050/io/2148e.1.cpin new file mode 100644 index 0000000..a78121c --- /dev/null +++ b/codeforces/1050/io/2148e.1.cpin @@ -0,0 +1,9 @@ +4 +3 2 +1 1 1 +4 2 +1 2 1 2 +8 2 +3 3 3 3 2 2 2 2 +6 3 +1 1 1 1 1 1 diff --git a/codeforces/1050/io/2148e.1.cpout b/codeforces/1050/io/2148e.1.cpout new file mode 100644 index 0000000..0b3a709 --- /dev/null +++ b/codeforces/1050/io/2148e.1.cpout @@ -0,0 +1,4 @@ +0 +7 +18 +11 diff --git a/codeforces/1050/io/2148e.cpin b/codeforces/1050/io/2148e.cpin new file mode 100644 index 0000000..a78121c --- /dev/null +++ b/codeforces/1050/io/2148e.cpin @@ -0,0 +1,9 @@ +4 +3 2 +1 1 1 +4 2 +1 2 1 2 +8 2 +3 3 3 3 2 2 2 2 +6 3 +1 1 1 1 1 1 diff --git a/codeforces/1050/io/2148e.cpout b/codeforces/1050/io/2148e.cpout new file mode 100644 index 0000000..568b16b --- /dev/null +++ b/codeforces/1050/io/2148e.cpout @@ -0,0 +1,9 @@ +0 +7 +18 +11 + +[code]: 0 +[time]: 2.91 ms +[debug]: false +[ok]: true diff --git a/codeforces/1050/io/2148e.expected b/codeforces/1050/io/2148e.expected new file mode 100644 index 0000000..0b3a709 --- /dev/null +++ b/codeforces/1050/io/2148e.expected @@ -0,0 +1,4 @@ +0 +7 +18 +11 diff --git a/codeforces/634/1335a.cc b/codeforces/634/1335a.cc new file mode 100644 index 0000000..84184f2 --- /dev/null +++ b/codeforces/634/1335a.cc @@ -0,0 +1,86 @@ +#include // {{{ + +#include +#ifdef __cpp_lib_ranges_enumerate +#include +namespace rv = std::views; +namespace rs = std::ranges; +#endif + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; + +#if __cplusplus >= 202002L +template constexpr T MIN = std::numeric_limits::min(); + +template constexpr T MAX = std::numeric_limits::max(); + +template [[nodiscard]] static T sc(auto &&x) { + return static_cast(x); +} + +template [[nodiscard]] static T sz(auto &&x) { + return static_cast(x.size()); +} +#endif + +static void NO() { std::cout << "NO\n"; } + +static void YES() { std::cout << "YES\n"; } + +template using vec = std::vector; + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define ff first +#define ss second + +#ifdef LOCAL +#define db(...) std::print(__VA_ARGS__) +#define dbln(...) std::println(__VA_ARGS__) +#else +#define db(...) +#define dbln(...) +#endif +// }}} + +void solve() { + u32 n; + cin >> n; + + u32 ans = (n + 1) / 2 - 1; + println("{}", ans); +} + +int main() { // {{{ + std::cin.exceptions(std::cin.failbit); + +#ifdef LOCAL + std::cerr.rdbuf(std::cout.rdbuf()); + std::cout.setf(std::ios::unitbuf); + std::cerr.setf(std::ios::unitbuf); +#else + std::cin.tie(nullptr)->sync_with_stdio(false); +#endif + + u32 tc = 1; + std::cin >> tc; + + for (u32 t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/634/1335b.cc b/codeforces/634/1335b.cc new file mode 100644 index 0000000..2c444e9 --- /dev/null +++ b/codeforces/634/1335b.cc @@ -0,0 +1,97 @@ +#include // {{{ + +#include +#ifdef __cpp_lib_ranges_enumerate +#include +namespace rv = std::views; +namespace rs = std::ranges; +#endif + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; + +#if __cplusplus >= 202002L +template constexpr T MIN = std::numeric_limits::min(); + +template constexpr T MAX = std::numeric_limits::max(); + +template [[nodiscard]] static T sc(auto &&x) { + return static_cast(x); +} + +template [[nodiscard]] static T sz(auto &&x) { + return static_cast(x.size()); +} +#endif + +static void NO() { std::cout << "NO\n"; } + +static void YES() { std::cout << "YES\n"; } + +template using vec = std::vector; + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define ff first +#define ss second + +#ifdef LOCAL +#define db(...) std::print(__VA_ARGS__) +#define dbln(...) std::println(__VA_ARGS__) +#else +#define db(...) +#define dbln(...) +#endif +// }}} + +void solve() { + u32 n, a, b; + cin >> n >> a >> b; + + string ans(n, 'a'); + + char c = 'a'; + for (u32 i = a - 1, count = 0; count < b; ++count, --i) { + ans[i] = c; + ++c; + } + + for (u32 i = a; i < n; ++i) { + ans[i] = ans[i - b]; + } + + println("{}", ans); +} + +int main() { // {{{ + std::cin.exceptions(std::cin.failbit); + +#ifdef LOCAL + std::cerr.rdbuf(std::cout.rdbuf()); + std::cout.setf(std::ios::unitbuf); + std::cerr.setf(std::ios::unitbuf); +#else + std::cin.tie(nullptr)->sync_with_stdio(false); +#endif + + u32 tc = 1; + std::cin >> tc; + + for (u32 t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/634/1335c.cc b/codeforces/634/1335c.cc new file mode 100644 index 0000000..60c1aa9 --- /dev/null +++ b/codeforces/634/1335c.cc @@ -0,0 +1,117 @@ +#include // {{{ + +#include +#ifdef __cpp_lib_ranges_enumerate +#include +namespace rv = std::views; +namespace rs = std::ranges; +#endif + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; + +#if __cplusplus >= 202002L +template constexpr T MIN = std::numeric_limits::min(); + +template constexpr T MAX = std::numeric_limits::max(); + +template [[nodiscard]] static T sc(auto &&x) { + return static_cast(x); +} + +template [[nodiscard]] static T sz(auto &&x) { + return static_cast(x.size()); +} +#endif + +static void NO() { std::cout << "NO\n"; } + +static void YES() { std::cout << "YES\n"; } + +template using vec = std::vector; + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define ff first +#define ss second + +#ifdef LOCAL +#define db(...) std::print(__VA_ARGS__) +#define dbln(...) std::println(__VA_ARGS__) +#else +#define db(...) +#define dbln(...) +#endif +// }}} + +void solve() { + u32 n; + cin >> n; + + vec a(n); + map f; + for (auto &e : a) { + cin >> e; + ++f[e]; + } + + i32 l = 0, r = n / 2; + + while (l <= r) { + i32 m = l + (r - l) / 2; + + bool ok = false; + for (auto &[number, frequency] : f) { + if (frequency >= m) { + i32 rest = (i32)f.size() - (frequency == m); + + if (rest >= m) { + ok = true; + break; + } + } + } + + if (ok) { + l = m + 1; + } else { + r = m - 1; + } + } + + println("{}", r); +} + +int main() { // {{{ + std::cin.exceptions(std::cin.failbit); + +#ifdef LOCAL + std::cerr.rdbuf(std::cout.rdbuf()); + std::cout.setf(std::ios::unitbuf); + std::cerr.setf(std::ios::unitbuf); +#else + std::cin.tie(nullptr)->sync_with_stdio(false); +#endif + + u32 tc = 1; + std::cin >> tc; + + for (u32 t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} + diff --git a/codeforces/io/e.out b/codeforces/634/1335d.cc similarity index 100% rename from codeforces/io/e.out rename to codeforces/634/1335d.cc diff --git a/codeforces/634/1335e1.cc b/codeforces/634/1335e1.cc new file mode 100644 index 0000000..30e08de --- /dev/null +++ b/codeforces/634/1335e1.cc @@ -0,0 +1,88 @@ +#include // {{{ + +#include +#ifdef __cpp_lib_ranges_enumerate +#include +namespace rv = std::views; +namespace rs = std::ranges; +#endif + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; + +#if __cplusplus >= 202002L +template constexpr T MIN = std::numeric_limits::min(); + +template constexpr T MAX = std::numeric_limits::max(); + +template [[nodiscard]] static T sc(auto &&x) { + return static_cast(x); +} + +template [[nodiscard]] static T sz(auto &&x) { + return static_cast(x.size()); +} +#endif + +static void NO() { std::cout << "NO\n"; } + +static void YES() { std::cout << "YES\n"; } + +template using vec = std::vector; + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define ff first +#define ss second + +#ifdef LOCAL +#define db(...) std::print(__VA_ARGS__) +#define dbln(...) std::println(__VA_ARGS__) +#else +#define db(...) +#define dbln(...) +#endif +// }}} + +void solve() { + u32 n; + cin >> n; + vec a(n); + for (auto &e : a) + cin >> e; + + cout << "hi\n"; +} + +int main() { // {{{ + std::cin.exceptions(std::cin.failbit); + +#ifdef LOCAL + std::cerr.rdbuf(std::cout.rdbuf()); + std::cout.setf(std::ios::unitbuf); + std::cerr.setf(std::ios::unitbuf); +#else + std::cin.tie(nullptr)->sync_with_stdio(false); +#endif + + u32 tc = 1; + std::cin >> tc; + + for (u32 t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/634/1335e2.cc b/codeforces/634/1335e2.cc new file mode 100644 index 0000000..c7f0f3d --- /dev/null +++ b/codeforces/634/1335e2.cc @@ -0,0 +1,123 @@ +#include // {{{ + +#include +#ifdef __cpp_lib_ranges_enumerate +#include +namespace rv = std::views; +namespace rs = std::ranges; +#endif + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u16 = uint16_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; + +#if __cplusplus >= 202002L +template constexpr T MIN = std::numeric_limits::min(); + +template constexpr T MAX = std::numeric_limits::max(); + +template [[nodiscard]] static T sc(auto &&x) { + return static_cast(x); +} + +template [[nodiscard]] static T sz(auto &&x) { + return static_cast(x.size()); +} +#endif + +static void NO() { std::cout << "NO\n"; } + +static void YES() { std::cout << "YES\n"; } + +template using vec = std::vector; + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define ff first +#define ss second + +#ifdef LOCAL +#define db(...) std::print(__VA_ARGS__) +#define dbln(...) std::println(__VA_ARGS__) +#else +#define db(...) +#define dbln(...) +#endif +// }}} + +void solve() { + u32 n; + cin >> n; + + vec a(n); + for (auto &e : a) + cin >> e; + + vec> f(200 + 1); + vec> pref(200 + 1, vec(n + 1, 0)); + + u32 ans = 0; + + for (u32 i = 1; i <= n; ++i) { + f[a[i - 1]].push_back(i); + + for (u32 x = 1; x <= 200; ++x) { + pref[x][i] = pref[x][i - 1]; + } + + ans = max(ans, ++pref[a[i - 1]][i]); + } + + for (u16 x = 1; x <= 200; ++x) { + for (u32 A = 1; A <= f[x].size() / 2; ++A) { + i32 l = f[x][A - 1] + 1; + i32 r = f[x][f[x].size() - A] - 1; + + if (l > r) { + continue; + } + + u32 B = 0; + for (u16 y = 1; y <= 200; ++y) { + B = max(B, pref[y][r] - pref[y][l - 1]); + } + + ans = max(ans, 2 * A + B); + } + } + + println("{}", ans); +} + +int main() { // {{{ + std::cin.exceptions(std::cin.failbit); + +#ifdef LOCAL + std::cerr.rdbuf(std::cout.rdbuf()); + std::cout.setf(std::ios::unitbuf); + std::cerr.setf(std::ios::unitbuf); +#else + std::cin.tie(nullptr)->sync_with_stdio(false); +#endif + + u32 tc = 1; + std::cin >> tc; + + for (u32 t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/634/1335f.cc b/codeforces/634/1335f.cc new file mode 100644 index 0000000..6b0dd27 --- /dev/null +++ b/codeforces/634/1335f.cc @@ -0,0 +1,91 @@ +#include // {{{ + +#include +#ifdef __cpp_lib_ranges_enumerate +#include +namespace rv = std::views; +namespace rs = std::ranges; +#endif + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; + +#if __cplusplus >= 202002L +template +constexpr T MIN = std::numeric_limits::min(); + +template +constexpr T MAX = std::numeric_limits::max(); + +template +[[nodiscard]] static T sc(auto&& x) { + return static_cast(x); +} + +template +[[nodiscard]] static T sz(auto&& x) { + return static_cast(x.size()); +} +#endif + +static void NO() { + std::cout << "NO\n"; +} + +static void YES() { + std::cout << "YES\n"; +} + +template +using vec = std::vector; + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define ff first +#define ss second + +#ifdef LOCAL +#define db(...) std::print(__VA_ARGS__) +#define dbln(...) std::println(__VA_ARGS__) +#else +#define db(...) +#define dbln(...) +#endif +// }}} + +void solve() { + +} + +int main() { // {{{ + std::cin.exceptions(std::cin.failbit); + +#ifdef LOCAL + std::cerr.rdbuf(std::cout.rdbuf()); + std::cout.setf(std::ios::unitbuf); + std::cerr.setf(std::ios::unitbuf); +#else + std::cin.tie(nullptr)->sync_with_stdio(false); +#endif + + u32 tc = 1; + std::cin >> tc; + + for (u32 t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/634/io/1068.1.cpin b/codeforces/634/io/1068.1.cpin new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/codeforces/634/io/1068.1.cpin @@ -0,0 +1 @@ +3 diff --git a/codeforces/634/io/1068.1.cpout b/codeforces/634/io/1068.1.cpout new file mode 100644 index 0000000..4c544cf --- /dev/null +++ b/codeforces/634/io/1068.1.cpout @@ -0,0 +1 @@ +3 10 5 16 8 4 2 1 diff --git a/codeforces/634/io/1068.cpin b/codeforces/634/io/1068.cpin new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/codeforces/634/io/1068.cpin @@ -0,0 +1 @@ +3 diff --git a/codeforces/634/io/1068.cpout b/codeforces/634/io/1068.cpout new file mode 100644 index 0000000..05d4cd9 --- /dev/null +++ b/codeforces/634/io/1068.cpout @@ -0,0 +1,5 @@ +3 +[code]: 0 +[time]: 2.44 ms +[debug]: false +[ok]: false diff --git a/codeforces/634/io/1068.expected b/codeforces/634/io/1068.expected new file mode 100644 index 0000000..4c544cf --- /dev/null +++ b/codeforces/634/io/1068.expected @@ -0,0 +1 @@ +3 10 5 16 8 4 2 1 diff --git a/codeforces/634/io/1069.1.cpin b/codeforces/634/io/1069.1.cpin new file mode 100644 index 0000000..a6c74b2 --- /dev/null +++ b/codeforces/634/io/1069.1.cpin @@ -0,0 +1 @@ +ATTCGGGA diff --git a/codeforces/634/io/1069.1.cpout b/codeforces/634/io/1069.1.cpout new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/codeforces/634/io/1069.1.cpout @@ -0,0 +1 @@ +3 diff --git a/codeforces/634/io/1069.cpin b/codeforces/634/io/1069.cpin new file mode 100644 index 0000000..a6c74b2 --- /dev/null +++ b/codeforces/634/io/1069.cpin @@ -0,0 +1 @@ +ATTCGGGA diff --git a/codeforces/634/io/1069.cpout b/codeforces/634/io/1069.cpout new file mode 100644 index 0000000..da0063d --- /dev/null +++ b/codeforces/634/io/1069.cpout @@ -0,0 +1,4 @@ + +[code]: 124 (TIMEOUT) +[time]: 2001.50 ms +[debug]: false diff --git a/codeforces/634/io/1069.expected b/codeforces/634/io/1069.expected new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/codeforces/634/io/1069.expected @@ -0,0 +1 @@ +3 diff --git a/codeforces/634/io/1335e1.1.cpin b/codeforces/634/io/1335e1.1.cpin new file mode 100644 index 0000000..0f00747 --- /dev/null +++ b/codeforces/634/io/1335e1.1.cpin @@ -0,0 +1,13 @@ +6 +8 +1 1 2 2 3 2 1 1 +3 +1 3 3 +4 +1 10 10 1 +1 +26 +2 +2 1 +3 +1 1 1 diff --git a/codeforces/634/io/1335e1.1.cpout b/codeforces/634/io/1335e1.1.cpout new file mode 100644 index 0000000..23acaef --- /dev/null +++ b/codeforces/634/io/1335e1.1.cpout @@ -0,0 +1,6 @@ +7 +2 +4 +1 +1 +3 diff --git a/codeforces/634/io/1335e1.cpin b/codeforces/634/io/1335e1.cpin new file mode 100644 index 0000000..0f00747 --- /dev/null +++ b/codeforces/634/io/1335e1.cpin @@ -0,0 +1,13 @@ +6 +8 +1 1 2 2 3 2 1 1 +3 +1 3 3 +4 +1 10 10 1 +1 +26 +2 +2 1 +3 +1 1 1 diff --git a/codeforces/634/io/1335e1.cpout b/codeforces/634/io/1335e1.cpout new file mode 100644 index 0000000..3852d25 --- /dev/null +++ b/codeforces/634/io/1335e1.cpout @@ -0,0 +1,11 @@ +hi +hi +hi +hi +hi +hi + +[code]: 0 +[time]: 4.03 ms +[debug]: false +[ok]: false diff --git a/codeforces/634/io/1335e1.expected b/codeforces/634/io/1335e1.expected new file mode 100644 index 0000000..23acaef --- /dev/null +++ b/codeforces/634/io/1335e1.expected @@ -0,0 +1,6 @@ +7 +2 +4 +1 +1 +3 diff --git a/codeforces/634/io/1335e2.1.cpin b/codeforces/634/io/1335e2.1.cpin new file mode 100644 index 0000000..0f00747 --- /dev/null +++ b/codeforces/634/io/1335e2.1.cpin @@ -0,0 +1,13 @@ +6 +8 +1 1 2 2 3 2 1 1 +3 +1 3 3 +4 +1 10 10 1 +1 +26 +2 +2 1 +3 +1 1 1 diff --git a/codeforces/634/io/1335e2.1.cpout b/codeforces/634/io/1335e2.1.cpout new file mode 100644 index 0000000..23acaef --- /dev/null +++ b/codeforces/634/io/1335e2.1.cpout @@ -0,0 +1,6 @@ +7 +2 +4 +1 +1 +3 diff --git a/codeforces/634/io/1335e2.cpin b/codeforces/634/io/1335e2.cpin new file mode 100644 index 0000000..0f00747 --- /dev/null +++ b/codeforces/634/io/1335e2.cpin @@ -0,0 +1,13 @@ +6 +8 +1 1 2 2 3 2 1 1 +3 +1 3 3 +4 +1 10 10 1 +1 +26 +2 +2 1 +3 +1 1 1 diff --git a/codeforces/634/io/1335e2.cpout b/codeforces/634/io/1335e2.cpout new file mode 100644 index 0000000..28082c2 --- /dev/null +++ b/codeforces/634/io/1335e2.cpout @@ -0,0 +1,11 @@ +7 +2 +4 +1 +1 +3 + +[code]: 0 +[time]: 3.38 ms +[debug]: false +[ok]: true diff --git a/codeforces/634/io/1335e2.expected b/codeforces/634/io/1335e2.expected new file mode 100644 index 0000000..23acaef --- /dev/null +++ b/codeforces/634/io/1335e2.expected @@ -0,0 +1,6 @@ +7 +2 +4 +1 +1 +3 diff --git a/codeforces/634/io/1933a.1.cpin b/codeforces/634/io/1933a.1.cpin new file mode 100644 index 0000000..65b02a1 --- /dev/null +++ b/codeforces/634/io/1933a.1.cpin @@ -0,0 +1,17 @@ +8 +3 +-2 3 -3 +1 +0 +2 +0 1 +1 +-99 +4 +10 -2 -3 7 +5 +-1 -2 -3 -4 -5 +6 +-41 22 -69 73 -15 -50 +12 +1 2 3 4 5 6 7 8 9 10 11 12 diff --git a/codeforces/634/io/1933a.1.cpout b/codeforces/634/io/1933a.1.cpout new file mode 100644 index 0000000..b878022 --- /dev/null +++ b/codeforces/634/io/1933a.1.cpout @@ -0,0 +1,8 @@ +8 +0 +1 +99 +22 +15 +270 +78 diff --git a/codeforces/634/io/1933a.cpin b/codeforces/634/io/1933a.cpin new file mode 100644 index 0000000..65b02a1 --- /dev/null +++ b/codeforces/634/io/1933a.cpin @@ -0,0 +1,17 @@ +8 +3 +-2 3 -3 +1 +0 +2 +0 1 +1 +-99 +4 +10 -2 -3 7 +5 +-1 -2 -3 -4 -5 +6 +-41 22 -69 73 -15 -50 +12 +1 2 3 4 5 6 7 8 9 10 11 12 diff --git a/codeforces/634/io/1933a.cpout b/codeforces/634/io/1933a.cpout new file mode 100644 index 0000000..14da5a5 --- /dev/null +++ b/codeforces/634/io/1933a.cpout @@ -0,0 +1,13 @@ +-2 3 -3 +0 +0 1 +-99 +10 -2 -3 7 +-1 -2 -3 -4 -5 +-41 22 -69 73 -15 -50 +1 2 3 4 5 6 7 8 9 10 11 12 + +[code]: 0 +[time]: 2.65 ms +[debug]: false +[matches]: false diff --git a/codeforces/634/io/1933a.expected b/codeforces/634/io/1933a.expected new file mode 100644 index 0000000..b878022 --- /dev/null +++ b/codeforces/634/io/1933a.expected @@ -0,0 +1,8 @@ +8 +0 +1 +99 +22 +15 +270 +78 diff --git a/codeforces/634/io/abc042a.1.cpin b/codeforces/634/io/abc042a.1.cpin new file mode 100644 index 0000000..959b81b --- /dev/null +++ b/codeforces/634/io/abc042a.1.cpin @@ -0,0 +1 @@ +5 5 7 diff --git a/codeforces/634/io/abc042a.1.cpout b/codeforces/634/io/abc042a.1.cpout new file mode 100644 index 0000000..f033a50 --- /dev/null +++ b/codeforces/634/io/abc042a.1.cpout @@ -0,0 +1 @@ +YES diff --git a/codeforces/634/io/abc042a.2.cpin b/codeforces/634/io/abc042a.2.cpin new file mode 100644 index 0000000..023b756 --- /dev/null +++ b/codeforces/634/io/abc042a.2.cpin @@ -0,0 +1 @@ +7 7 5 diff --git a/codeforces/634/io/abc042a.2.cpout b/codeforces/634/io/abc042a.2.cpout new file mode 100644 index 0000000..5e35d1b --- /dev/null +++ b/codeforces/634/io/abc042a.2.cpout @@ -0,0 +1 @@ +NO diff --git a/codeforces/634/io/abc042a.cpin b/codeforces/634/io/abc042a.cpin new file mode 100644 index 0000000..ad16ad6 --- /dev/null +++ b/codeforces/634/io/abc042a.cpin @@ -0,0 +1,3 @@ +2 +5 5 7 +7 7 5 diff --git a/codeforces/634/io/abc042a.cpout b/codeforces/634/io/abc042a.cpout new file mode 100644 index 0000000..6e8bb3e --- /dev/null +++ b/codeforces/634/io/abc042a.cpout @@ -0,0 +1,7 @@ +17 +19 + +[code]: 0 +[time]: 2.68 ms +[debug]: false +[ok]: false diff --git a/codeforces/634/io/abc042a.expected b/codeforces/634/io/abc042a.expected new file mode 100644 index 0000000..823d3f6 --- /dev/null +++ b/codeforces/634/io/abc042a.expected @@ -0,0 +1,2 @@ +YES +NO diff --git a/codeforces/920/f b/codeforces/920/f new file mode 100755 index 0000000..1c4d8bf Binary files /dev/null and b/codeforces/920/f differ diff --git a/codeforces/920/f.cc b/codeforces/920/f.cc new file mode 100644 index 0000000..780fea3 --- /dev/null +++ b/codeforces/920/f.cc @@ -0,0 +1,112 @@ +#include // {{{ + +#include +#ifdef __cpp_lib_ranges_enumerate +#include +namespace rv = std::views; +namespace rs = std::ranges; +#endif + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; + +#if __cplusplus >= 202002L +template +constexpr T MIN = std::numeric_limits::min(); + +template +constexpr T MAX = std::numeric_limits::max(); + +template +[[nodiscard]] static T sc(auto&& x) { + return static_cast(x); +} + +template +[[nodiscard]] static T sz(auto&& x) { + return static_cast(x.size()); +} +#endif + +static void NO() { + std::cout << "NO\n"; +} + +static void YES() { + std::cout << "YES\n"; +} + +template +using vec = std::vector; + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define ff first +#define ss second + +#ifdef LOCAL +#define db(...) std::print(__VA_ARGS__) +#define dbln(...) std::println(__VA_ARGS__) +#else +#define db(...) +#define dbln(...) +#endif +// }}} + +void solve() { + u32 n, q; + cin >> n >> q; + + vec a(n); + for (auto& e : a) + cin >> e; + + u32 block_size = sqrt(n); + + u32 s, d, k; + for (u32 i = 0; i < q; ++i) { + cin >> s >> d >> k; + + i64 ans = 0; + u32 index = s; + for (i64 i = 1; i <= k; ++i, index += d) { + ans += i * a[index - 1]; + } + + cout << ans << " \n"[i == q - 1]; + } +} + +int main() { // {{{ + std::cin.exceptions(std::cin.failbit); + +#ifdef LOCAL + std::cerr.rdbuf(std::cout.rdbuf()); + std::cout.setf(std::ios::unitbuf); + std::cerr.setf(std::ios::unitbuf); +#else + std::cin.tie(nullptr)->sync_with_stdio(false); +#endif + + u32 tc = 1; + + std::cin >> tc; + + for (u32 t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/920/io/f.expected b/codeforces/920/io/f.expected new file mode 100644 index 0000000..61523db --- /dev/null +++ b/codeforces/920/io/f.expected @@ -0,0 +1,5 @@ +5 1 3 +-600000000 +22 12 55 +600000000 +171 42 118 66 -108 23 2 diff --git a/codeforces/920/io/f.in b/codeforces/920/io/f.in new file mode 100644 index 0000000..9acf609 --- /dev/null +++ b/codeforces/920/io/f.in @@ -0,0 +1,26 @@ +5 +3 3 +1 1 2 +1 2 2 +2 2 1 +1 1 2 +3 1 +-100000000 -100000000 -100000000 +1 1 3 +5 3 +1 2 3 4 5 +1 2 3 +2 3 2 +1 1 5 +3 1 +100000000 100000000 100000000 +1 1 3 +7 7 +34 87 5 42 -44 66 -32 +2 2 2 +4 3 1 +1 3 2 +6 2 1 +5 2 2 +2 5 2 +6 1 2 diff --git a/codeforces/920/io/f.out b/codeforces/920/io/f.out new file mode 100644 index 0000000..52267eb --- /dev/null +++ b/codeforces/920/io/f.out @@ -0,0 +1,10 @@ +5 1 3 +-600000000 +22 12 55 +600000000 +171 42 118 66 -108 23 2 + +[code]: 0 +[time]: 2.93 ms +[debug]: false +[matches]: true diff --git a/codeforces/920/solution.cc b/codeforces/920/solution.cc new file mode 100644 index 0000000..6b0dd27 --- /dev/null +++ b/codeforces/920/solution.cc @@ -0,0 +1,91 @@ +#include // {{{ + +#include +#ifdef __cpp_lib_ranges_enumerate +#include +namespace rv = std::views; +namespace rs = std::ranges; +#endif + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; + +#if __cplusplus >= 202002L +template +constexpr T MIN = std::numeric_limits::min(); + +template +constexpr T MAX = std::numeric_limits::max(); + +template +[[nodiscard]] static T sc(auto&& x) { + return static_cast(x); +} + +template +[[nodiscard]] static T sz(auto&& x) { + return static_cast(x.size()); +} +#endif + +static void NO() { + std::cout << "NO\n"; +} + +static void YES() { + std::cout << "YES\n"; +} + +template +using vec = std::vector; + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define ff first +#define ss second + +#ifdef LOCAL +#define db(...) std::print(__VA_ARGS__) +#define dbln(...) std::println(__VA_ARGS__) +#else +#define db(...) +#define dbln(...) +#endif +// }}} + +void solve() { + +} + +int main() { // {{{ + std::cin.exceptions(std::cin.failbit); + +#ifdef LOCAL + std::cerr.rdbuf(std::cout.rdbuf()); + std::cout.setf(std::ios::unitbuf); + std::cerr.setf(std::ios::unitbuf); +#else + std::cin.tie(nullptr)->sync_with_stdio(false); +#endif + + u32 tc = 1; + std::cin >> tc; + + for (u32 t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/962/f.cc b/codeforces/962/f.cc new file mode 100644 index 0000000..4f7145c --- /dev/null +++ b/codeforces/962/f.cc @@ -0,0 +1,148 @@ +#include // {{{ + +#include +#ifdef __cpp_lib_ranges_enumerate +#include +namespace rv = std::views; +namespace rs = std::ranges; +#endif + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; + +#if __cplusplus >= 202002L +template +constexpr T MIN = std::numeric_limits::min(); + +template +constexpr T MAX = std::numeric_limits::max(); + +template +[[nodiscard]] static T sc(auto&& x) { + return static_cast(x); +} + +template +[[nodiscard]] static T sz(auto&& x) { + return static_cast(x.size()); +} +#endif + +static void NO() { + std::cout << "NO\n"; +} + +static void YES() { + std::cout << "YES\n"; +} + +template +using vec = std::vector; + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define ff first +#define ss second + +#ifdef LOCAL +#define db(...) std::print(__VA_ARGS__) +#define dbln(...) std::println(__VA_ARGS__) +#else +#define db(...) +#define dbln(...) +#endif +// }}} + +void solve() { + i64 n, k; + cin >> n >> k; + vector a(n), b(n); + for (auto& e : a) + cin >> e; + for (auto& e : b) + cin >> e; + + i64 l = 0, r = *max_element(a.begin(), a.end()); + vector last_a(n); + i64 ans = 0, operations = 0; + + while (l <= r) { + i64 m = l + (r - l) / 2, s = 0, o = 0; + + for (u32 i = 0; i < n; ++i) { + if (a[i] >= m) { + i64 O = (a[i] - m) / b[i] + 1; + s += O * a[i] - b[i] * O * (O - 1) / 2; + o += O; + } + } + + if (o <= k) { + ans = s; + operations = o; + for (u32 i = 0; i < n; ++i) { + i64 O = (a[i] - m) / b[i] + 1; + if (a[i] >= m) { + last_a[i] = a[i] - O * b[i]; + } + } + r = m - 1; + } else + l = m + 1; + } + + auto brute_force = [&]() { + set> tree; + i64 ans = 0; + for (i64 i = 0; i < n; ++i) + if (last_a[i] > 0) + tree.emplace(last_a[i], i); + for (i64 _ = 0; _ < k && !tree.empty(); ++_) { + auto it = prev(tree.end()); + auto [score, i] = *it; + tree.erase(it); + ans += score; + if (score > b[i]) + tree.emplace(score - b[i], i); + } + return ans; + }; + + k -= operations; + if (k > 0) + ans += brute_force(); + cout << ans << '\n'; +} + +int main() { // {{{ + std::cin.exceptions(std::cin.failbit); + +#ifdef LOCAL + std::cerr.rdbuf(std::cout.rdbuf()); + std::cout.setf(std::ios::unitbuf); + std::cerr.setf(std::ios::unitbuf); +#else + std::cin.tie(nullptr)->sync_with_stdio(false); +#endif + + u32 tc = 1; + std::cin >> tc; + + for (u32 t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/962/io/f.expected b/codeforces/962/io/f.expected new file mode 100644 index 0000000..7d97a58 --- /dev/null +++ b/codeforces/962/io/f.expected @@ -0,0 +1,5 @@ +21 +349 +27 +500000500000 +47 diff --git a/codeforces/962/io/f.in b/codeforces/962/io/f.in new file mode 100644 index 0000000..7504599 --- /dev/null +++ b/codeforces/962/io/f.in @@ -0,0 +1,17 @@ +5 +3 4 +5 6 7 +2 3 4 +5 9 +32 52 68 64 14 +18 14 53 24 8 +5 1000 +1 2 3 4 5 +5 4 3 2 1 +1 1000000 +1000000 +1 +10 6 +3 3 5 10 6 8 6 8 7 7 +6 1 7 4 1 1 8 9 3 1 + diff --git a/codeforces/962/io/f.out b/codeforces/962/io/f.out new file mode 100644 index 0000000..faa4461 --- /dev/null +++ b/codeforces/962/io/f.out @@ -0,0 +1,10 @@ +21 +349 +27 +500000500000 +47 + +[code]: 0 +[time]: 2.82 ms +[debug]: false +[matches]: false diff --git a/codeforces/io/e.in b/codeforces/io/e.in deleted file mode 100644 index aa82e59..0000000 --- a/codeforces/io/e.in +++ /dev/null @@ -1,13 +0,0 @@ -12 -6 5 2 2 5 3 -4 1 2 1 4 1 -1 4 1 3 1 1 -5 5 1 4 5 2 -4 4 1 1 4 4 -10 10 1 6 10 8 -10 10 2 6 10 7 -10 10 9 1 8 1 -10 10 8 1 10 2 -10 10 1 1 2 1 -10 10 1 3 4 1 -10 10 3 1 1 1