fragment-header
fragment-markdown
홈
로그인
로그아웃
내 블로그
설정
로그인
AtCoder Beginner Contest 422-C (C++) AtCoder AAC Contest
최초 업로드: 2025-09-07 07:15:00
최근 수정 시간: 2025-09-07 07:15:15
게시자: rlatjwls3333
카테고리: Atcoder
조회수: 8
# C - AtCoder AAC Contest [문제 링크](https://atcoder.jp/contests/abc422/tasks/abc422_c) ## Problem Statement Takahashi has some letters. Each letter he has is `A`, `B`, or `C`. Initially, he has \$n\_A\$ letters `A`, \$n\_B\$ letters `B`, and \$n\_C\$ letters `C`. He can hold one contest by using one letter `A`, one letter `C`, and **additionally any one letter**, for a total of three letters. Specifically, he can hold `AAC` (two `A` and one `C`), `ABC` (one of each), or `ACC` (one `A` and two `C`). He wants to hold as many contests as possible using the letters he currently has. Find the **maximum** number of contests he can hold. \$T\$ test cases are given; report the answer for each of them. ## Constraints * \$1 \le T \le 2 \times 10^{5}\$ * For each test case: * \$0 \le n\_A \le 10^{9}\$ * \$0 \le n\_B \le 10^{9}\$ * \$0 \le n\_C \le 10^{9}\$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $T$ $testcase_1$ $testcase_2$ $\vdots$ $testcase_T$ Each `testcase_i` (\$1 \le i \le T\$) is given as: $n_A$ $n_B$ $n_C$ ## Output Output over \$T\$ lines. On the \$i\$-th line (\$1 \le i \le T\$), output the answer to the \$i\$-th test case. ## 풀이 먼저 가장 필요없는 B와 무조건 포함해야 하는 A와 C를 사용하여 개수를 찾고, 쓰고 남은 것들로 나머지를 구성하면 된다. ``` c++ #include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while(t--) { ll a, b, c; cin >> a >> b >> c; ll cnt = min({a, b, c}); a -= cnt; b -= cnt; c -= cnt; cnt += min({a, c, (a+b+c)/3}); cout << cnt << '\n'; } } ```