From 83168354213cb2e4a67da26eae92eb4ef97c61c1 Mon Sep 17 00:00:00 2001 From: eucha09 Date: Sun, 30 Jul 2023 15:34:54 +0900 Subject: [PATCH 1/3] upload: part1 quiz 1475 codes(cpp, py) --- .../1475.cpp" | 24 +++++++++++++++++++ .../1475.py" | 13 ++++++++++ 2 files changed, 37 insertions(+) create mode 100644 "Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemA_\353\260\251\353\262\210\355\230\270/1475.cpp" create mode 100644 "Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemA_\353\260\251\353\262\210\355\230\270/1475.py" diff --git "a/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemA_\353\260\251\353\262\210\355\230\270/1475.cpp" "b/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemA_\353\260\251\353\262\210\355\230\270/1475.cpp" new file mode 100644 index 0000000..fdf4fe7 --- /dev/null +++ "b/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemA_\353\260\251\353\262\210\355\230\270/1475.cpp" @@ -0,0 +1,24 @@ +#include +#include +using namespace std; + +int main() +{ + int N; + int cnt[10] = {0, }; + + scanf("%d", &N); + while (N > 0) + { + cnt[N % 10]++; + N /= 10; + } + + int ans = (cnt[6] + cnt[9] + 1) / 2; + for (int i = 0; i < 9; i++) + if (i != 6) + ans = max(ans, cnt[i]); + + printf("%d\n", ans); + return 0; +} diff --git "a/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemA_\353\260\251\353\262\210\355\230\270/1475.py" "b/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemA_\353\260\251\353\262\210\355\230\270/1475.py" new file mode 100644 index 0000000..9bedd7f --- /dev/null +++ "b/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemA_\353\260\251\353\262\210\355\230\270/1475.py" @@ -0,0 +1,13 @@ +N = int(input()) +cnt = [0]*10 + +while N > 0: + cnt[N%10] += 1 + N //= 10 + +ans = (cnt[6] + cnt[9] + 1) // 2 +for i in range(9): + if i != 6: + ans = max(ans, cnt[i]) + +print(ans) From 8d0efb94fd5262808b98797fa74e9987b1cedac6 Mon Sep 17 00:00:00 2001 From: eucha09 Date: Sun, 30 Jul 2023 15:44:17 +0900 Subject: [PATCH 2/3] upload: part1 quiz 7795 codes(cpp, py) --- .../7795.cpp" | 38 +++++++++++++++++++ .../7795.py" | 18 +++++++++ 2 files changed, 56 insertions(+) create mode 100644 "Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemC_\353\250\271\354\235\204\352\262\203\354\235\270\352\260\200\353\250\271\355\236\220\352\262\203\354\235\270\352\260\200/7795.cpp" create mode 100644 "Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemC_\353\250\271\354\235\204\352\262\203\354\235\270\352\260\200\353\250\271\355\236\220\352\262\203\354\235\270\352\260\200/7795.py" diff --git "a/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemC_\353\250\271\354\235\204\352\262\203\354\235\270\352\260\200\353\250\271\355\236\220\352\262\203\354\235\270\352\260\200/7795.cpp" "b/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemC_\353\250\271\354\235\204\352\262\203\354\235\270\352\260\200\353\250\271\355\236\220\352\262\203\354\235\270\352\260\200/7795.cpp" new file mode 100644 index 0000000..b763d92 --- /dev/null +++ "b/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemC_\353\250\271\354\235\204\352\262\203\354\235\270\352\260\200\353\250\271\355\236\220\352\262\203\354\235\270\352\260\200/7795.cpp" @@ -0,0 +1,38 @@ +#include +#include +#include +using namespace std; + +int main() +{ + int T; + + scanf("%d", &T); + while (T--) + { + int N, M; + scanf("%d %d", &N, &M); + + vector a(N); + for (int i = 0; i < N; i++) + scanf("%d", &a[i]); + + vector b(M); + for (int i = 0; i < M; i++) + scanf("%d", &b[i]); + + sort(a.begin(), a.end()); + sort(b.begin(), b.end()); + + int ans = 0; + int bi = 0; + for (int i = 0; i < N; i++) + { + while (bi < M && b[bi] < a[i]) + bi++; + ans += bi; + } + printf("%d\n", ans); + } + return 0; +} diff --git "a/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemC_\353\250\271\354\235\204\352\262\203\354\235\270\352\260\200\353\250\271\355\236\220\352\262\203\354\235\270\352\260\200/7795.py" "b/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemC_\353\250\271\354\235\204\352\262\203\354\235\270\352\260\200\353\250\271\355\236\220\352\262\203\354\235\270\352\260\200/7795.py" new file mode 100644 index 0000000..acf6ce7 --- /dev/null +++ "b/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemC_\353\250\271\354\235\204\352\262\203\354\235\270\352\260\200\353\250\271\355\236\220\352\262\203\354\235\270\352\260\200/7795.py" @@ -0,0 +1,18 @@ +T = int(input()) + +for _ in range(T): + N, M = map(int, input().split()) + + a = list(map(int, input().split())) + b = list(map(int, input().split())) + + a.sort() + b.sort() + + ans = 0 + bi = 0 + for i in range(N): + while bi < M and b[bi] < a[i]: + bi += 1 + ans += bi + print(ans) From 0cba7c1035408a4ace5f90b56dfab9b18526ee31 Mon Sep 17 00:00:00 2001 From: eucha09 Date: Sun, 30 Jul 2023 17:37:48 +0900 Subject: [PATCH 3/3] upload: part1 quiz 15317 codes(cpp, py) --- .../15317.cpp" | 46 +++++++++++++++++++ .../15317.py" | 24 ++++++++++ 2 files changed, 70 insertions(+) create mode 100644 "Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemE_\353\217\231\353\260\251\353\263\264\354\210\230/15317.cpp" create mode 100644 "Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemE_\353\217\231\353\260\251\353\263\264\354\210\230/15317.py" diff --git "a/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemE_\353\217\231\353\260\251\353\263\264\354\210\230/15317.cpp" "b/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemE_\353\217\231\353\260\251\353\263\264\354\210\230/15317.cpp" new file mode 100644 index 0000000..046c856 --- /dev/null +++ "b/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemE_\353\217\231\353\260\251\353\263\264\354\210\230/15317.cpp" @@ -0,0 +1,46 @@ +#include +#include +#include +using namespace std; +typedef long long ll; + +ll calc_need_amount(vector &cost, vector &budget, int assign_cnt) +{ + ll need_amount = 0; + for (int i = 0; i < assign_cnt; i++) + need_amount += max(cost[i] - budget[budget.size() - assign_cnt + i], 0); + return need_amount; +} + +int main() +{ + int N, M, X; + + scanf("%d %d %d", &N, &M, &X); + + vector cost(N); + for (int i = 0; i < N; i++) + scanf("%d", &cost[i]); + + vector budget(M); + for (int i = 0; i < M; i++) + scanf("%d", &budget[i]); + + sort(cost.begin(), cost.end()); + sort(budget.begin(), budget.end()); + + int l = 0, r = min(N, M), ans = 0; + while (l <= r) + { + int m = (l + r) / 2; + if (calc_need_amount(cost, budget, m) <= X) + { + ans = m; + l = m + 1; + } + else + r = m - 1; + } + printf("%d\n", ans); + return 0; +} diff --git "a/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemE_\353\217\231\353\260\251\353\263\264\354\210\230/15317.py" "b/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemE_\353\217\231\353\260\251\353\263\264\354\210\230/15317.py" new file mode 100644 index 0000000..4e20acc --- /dev/null +++ "b/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemE_\353\217\231\353\260\251\353\263\264\354\210\230/15317.py" @@ -0,0 +1,24 @@ +def calc_need_amount(cost, budget, assign_cnt): + need_amount = 0 + for i in range(assign_cnt): + need_amount += max(cost[i] - budget[len(budget)-assign_cnt+i], 0) + return need_amount + +N, M, X = map(int, input().split()) + +cost = list(map(int, input().split())) +budget = list(map(int, input().split())) + +cost.sort() +budget.sort() + +l, r, ans = 0, min(N, M), 0 +while l <= r: + m = (l + r) // 2 + if calc_need_amount(cost, budget, m) <= X: + ans = m + l = m + 1 + else: + r = m - 1 + +print(ans)