Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
84537 刘泽熙 19选班长II C++ Accepted 1 MS 308 KB 661 2024-07-16 09:55:18

Tests(10/10):


Code:

#include <bits/stdc++.h> using namespace std; int main() { int i = 0, j = 0, n = 0, A = 0, B = 0, C = 0; int arr[10001] = {0}; while (1) { cin >> arr[i]; if (arr[i] == -1) break; i++; n++; } for (i = 0; i < n; i++) { if (arr[i] == 1) A++; else if (arr[i] == 2) B++; else if (arr[i] == 3) C++; } cout << "A=" << A << endl; cout << "B=" << B << endl; cout << "C=" << C << endl; cout << "Tot=" << n << endl; if (A > n / 2) cout << "A-yes" << endl; else if (B > n / 2) cout << "B-yes" << endl; else if (C > n / 2) cout << "C-yes" << endl; else cout << "all-NO" << endl; return 0; }