Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
140058 刘梓含 19选班长II C++ Accepted 1 MS 276 KB 818 2025-12-13 14:50:14

Tests(10/10):


Code:

#include<bits/stdc++.h> using namespace std; int main(){ int a=0,b[4] = {0},n=0; while(a != -1) { cin >> a; if(a >= 1 && a <= 3) { b[a]++; } n++; } cout<<"A="<<b[1]<<endl; cout<<"B="<<b[2]<<endl; cout<<"C="<<b[3]<<endl; cout<<"Tot="<<n-1<<endl; int x,max=0; for(int i = 1;i <= 3;i++) { if(b[i] > max) { max = b[i]; x = i; } } if(x == 1) { if(b[1] * 2 > n-1) { cout <<"A-yes"; }else { cout << "all-NO"; } } if(x == 2) { if(b[2] * 2 > n-1) { cout << "B-yes"; }else { cout << "all-NO"; } } if(x == 3) { if(b[3] * 2 > n-1) { cout << "C-yes"; } else { cout << "all-NO"; } } return 0; }