diff --git a/codeforces/rounds/797/a.cpp b/codeforces/rounds/797/a.cpp new file mode 100644 index 0000000..b64fbe5 --- /dev/null +++ b/codeforces/rounds/797/a.cpp @@ -0,0 +1,38 @@ +#include + +using namespace std; + +void test_case(int tc){ + int n; + cin >> n; + + int result = n / 3 + 2; + if(n % 3 == 0) { + result = n / 3 + 1; + } + int r2 = result - 1; + if(n == 7){ + r2 = 2; + } + int lowest = n - result - r2; + + cout << r2 << " " << result << " " << lowest << '\n'; +} + + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int t; + cin >> t; + + for(int tc = 1; tc <= t; ++tc){ + test_case(tc); + } + + cout << flush; + + return 0; +} \ No newline at end of file diff --git a/codeforces/rounds/797/b.cpp b/codeforces/rounds/797/b.cpp new file mode 100644 index 0000000..e185b45 --- /dev/null +++ b/codeforces/rounds/797/b.cpp @@ -0,0 +1,66 @@ +#include + +using namespace std; + +void test_case(int tc){ + int n; + cin >> n; + + vector a(n); + vector b(n); + + for (size_t i = 0; i < n; i++){ + cin >> a[i]; + } + + for (size_t i = 0; i < n; i++){ + cin >> b[i]; + } + + bool result = true; + + int exactdif = INT32_MAX; + int hightestdif = 0; + bool onlyzeroes = true; + + for(size_t i = 0; i < n; ++i){ + auto ax = a[i], bx = b[i]; + auto d = ax - bx; + + if(bx == 0){ + hightestdif = max(hightestdif, d); + } else { + onlyzeroes = false; + if(exactdif == INT32_MAX){ + exactdif = d; + } else if(exactdif != d){ + result = false; + break; + } + } + } + + if(hightestdif > exactdif){ + result = false; + } + + cout << (result || onlyzeroes ? "YES" : "NO") << '\n'; +} + + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int t; + cin >> t; + + for(int tc = 1; tc <= t; ++tc){ + test_case(tc); + } + + cout << flush; + + return 0; +} \ No newline at end of file diff --git a/codeforces/rounds/797/c.cpp b/codeforces/rounds/797/c.cpp new file mode 100644 index 0000000..509c499 --- /dev/null +++ b/codeforces/rounds/797/c.cpp @@ -0,0 +1,48 @@ +#include + +using namespace std; + +typedef unsigned long long ull; + +void test_case(int tc){ + int n; + cin >> n; + + vector s(n); + vector f(n); + + for(size_t i = 0; i < n; ++i){ + cin >> s[i]; + } + + for(size_t i = 0; i < n; ++i){ + cin >> f[i]; + + if(i != 0){ + cout << f[i] - max(s[i], f[i-1]) << " "; + } else { + cout << f[i] - s[i] << " "; + } + } + + cout << "\n"; + +} + + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int t; + cin >> t; + + for(int tc = 1; tc <= t; ++tc){ + test_case(tc); + } + + cout << flush; + + return 0; +} \ No newline at end of file diff --git a/codeforces/rounds/797/d.cpp b/codeforces/rounds/797/d.cpp new file mode 100644 index 0000000..e34da8b --- /dev/null +++ b/codeforces/rounds/797/d.cpp @@ -0,0 +1,68 @@ +#include + +using namespace std; + +void test_case(int tc){ + int n, k; + cin >> n >> k; + + vector strip; + + int blacks = 0; + int whites = 0; + for(int i = 0; i < k; ++i){ + char c; + cin >> c; + + if(c == 'B'){ + blacks++; + strip.push_back(true); + } else{ + whites++; + strip.push_back(false); + } + } + + int min_whites = whites; + + for(int i = 0; i < n - k; ++i){ + char c; + cin >> c; + + if(strip[i]){ + blacks--; + } else { + whites--; + } + + if(c == 'B'){ + blacks++; + strip.push_back(true); + } else { + whites++; + strip.push_back(false); + } + + min_whites = min(min_whites, whites); + } + + cout << min_whites << '\n'; +} + + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int t; + cin >> t; + + for(int tc = 1; tc <= t; ++tc){ + test_case(tc); + } + + cout << flush; + + return 0; +} \ No newline at end of file diff --git a/codeforces/rounds/797/e.cpp b/codeforces/rounds/797/e.cpp new file mode 100644 index 0000000..cc85326 --- /dev/null +++ b/codeforces/rounds/797/e.cpp @@ -0,0 +1,76 @@ +#include + +using namespace std; + +void test_case(int tc){ + int n, k; + + cin >> n >> k; + + vector> modulos(k); + + for(int i = 0; i < n; ++i){ + int s; + cin >> s; + + modulos[s % k].push_back(s); + } + + for(auto v : modulos){ + sort(v.begin(), v.end()); + } + + unsigned long long result = 0; + + for(int i = k - 1; i > 0; i--){ + while(!modulos[i].empty() && !modulos[k-i].empty()){ + int a = modulos[i].back(), b = modulos[k - 1].back(); + modulos[i].pop_back(); + modulos[k-1].pop_back(); + + result += (a + b) / k; + } + } + + while(modulos[0].size() > 1){ + int a = modulos[0].back(); + modulos[0].pop_back(); + int b = modulos[0].back(); + modulos[0].pop_back(); + + result += (a + b) / k; + } + + for(int i = 0; i < k; ++i){ + for(int j = i + 1; j < k; ++j){ + while(!modulos[i].empty() && !modulos[j].empty()){ + int a = modulos[i].back(), b = modulos[j].back(); + modulos[i].pop_back(); + modulos[j].pop_back(); + + result += (a + b) / k; + } + } + } + + cout << result << '\n'; + +} + + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int t; + cin >> t; + + for(int tc = 1; tc <= t; ++tc){ + test_case(tc); + } + + cout << flush; + + return 0; +} \ No newline at end of file diff --git a/codeforces/rounds/797/f.cpp b/codeforces/rounds/797/f.cpp new file mode 100644 index 0000000..0c03bec --- /dev/null +++ b/codeforces/rounds/797/f.cpp @@ -0,0 +1,25 @@ +#include + +using namespace std; + +void test_case(int tc){ + +} + + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int t; + cin >> t; + + for(int tc = 1; tc <= t; ++tc){ + test_case(tc); + } + + cout << flush; + + return 0; +} \ No newline at end of file diff --git a/codeforces/rounds/797/g.cpp b/codeforces/rounds/797/g.cpp new file mode 100644 index 0000000..0c03bec --- /dev/null +++ b/codeforces/rounds/797/g.cpp @@ -0,0 +1,25 @@ +#include + +using namespace std; + +void test_case(int tc){ + +} + + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int t; + cin >> t; + + for(int tc = 1; tc <= t; ++tc){ + test_case(tc); + } + + cout << flush; + + return 0; +} \ No newline at end of file