From 27d00340b9ab0bfeeb1cfd8190431d7323e0e1d7 Mon Sep 17 00:00:00 2001 From: Philippe Zwietering Date: Sat, 18 Jun 2022 17:07:46 +0200 Subject: [PATCH] CF EDU 130, finished a and b --- codeforces/educational_rounds/130/a.cpp | 37 ++++++++++++++++++++++++ codeforces/educational_rounds/130/b.cpp | 38 +++++++++++++++++++++++++ codeforces/educational_rounds/130/c.cpp | 36 +++++++++++++++++++++++ codeforces/educational_rounds/130/d.cpp | 25 ++++++++++++++++ codeforces/educational_rounds/130/e.cpp | 25 ++++++++++++++++ codeforces/educational_rounds/130/f.cpp | 25 ++++++++++++++++ 6 files changed, 186 insertions(+) create mode 100644 codeforces/educational_rounds/130/a.cpp create mode 100644 codeforces/educational_rounds/130/b.cpp create mode 100644 codeforces/educational_rounds/130/c.cpp create mode 100644 codeforces/educational_rounds/130/d.cpp create mode 100644 codeforces/educational_rounds/130/e.cpp create mode 100644 codeforces/educational_rounds/130/f.cpp diff --git a/codeforces/educational_rounds/130/a.cpp b/codeforces/educational_rounds/130/a.cpp new file mode 100644 index 0000000..59aba4d --- /dev/null +++ b/codeforces/educational_rounds/130/a.cpp @@ -0,0 +1,37 @@ +#include + +using namespace std; + +void test_case(int tc){ + int n, m; + cin >> n >> m; + + int distance = 0; + + for(int i = 0; i < n; ++i){ + int a; + cin >> a; + + distance += a; + } + + cout << max(0, distance - m) << '\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/educational_rounds/130/b.cpp b/codeforces/educational_rounds/130/b.cpp new file mode 100644 index 0000000..24adcd8 --- /dev/null +++ b/codeforces/educational_rounds/130/b.cpp @@ -0,0 +1,38 @@ +#include + +using namespace std; + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int n, q; + cin >> n >> q; + + vector p(n); + for(int i = 0; i < n; ++i){ + cin >> p[i]; + } + + sort(p.begin(), p.end()); + + vector bottom_sums(n+1); + + uint64_t sum = 0; + for(int i = 0; i <= n; ++i){ + bottom_sums[i] = sum; + sum += p[i]; + } + + for(int i = 0; i < q; ++i){ + int x, y; + cin >> x >> y; + + uint64_t ans = bottom_sums[n - x + y] - bottom_sums[n - x]; + cout << ans << '\n'; + } + + cout << flush; + + return 0; +} \ No newline at end of file diff --git a/codeforces/educational_rounds/130/c.cpp b/codeforces/educational_rounds/130/c.cpp new file mode 100644 index 0000000..3c046b4 --- /dev/null +++ b/codeforces/educational_rounds/130/c.cpp @@ -0,0 +1,36 @@ +#include + +using namespace std; + +void test_case(int tc){ + int n; + cin >> n; + + vector s(n), t(n); + for(int i = 0; i < n; ++i){ + cin >> s[i]; + } + for(int i = 0; i < n; ++i){ + cin >> t[i]; + } + + +} + + + +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/educational_rounds/130/d.cpp b/codeforces/educational_rounds/130/d.cpp new file mode 100644 index 0000000..0c03bec --- /dev/null +++ b/codeforces/educational_rounds/130/d.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/educational_rounds/130/e.cpp b/codeforces/educational_rounds/130/e.cpp new file mode 100644 index 0000000..0c03bec --- /dev/null +++ b/codeforces/educational_rounds/130/e.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/educational_rounds/130/f.cpp b/codeforces/educational_rounds/130/f.cpp new file mode 100644 index 0000000..0c03bec --- /dev/null +++ b/codeforces/educational_rounds/130/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