NC229584. Strength team
描述
A football team has 23 players, and each player has an integer comprehensive quality value. We sort and number the players according to their comprehensive quality value from large to small. That is, the largest comprehensive quality value is No. 1, followed by No. 2, and the smallest comprehensive quality value is No. 23.
When comparing the comprehensive strength of two teams, we compare them according to the players with the same number. If there are many players of a team whose comprehensive quality value is large in pairwise comparison, we think that this team has strong strength and will win the game.
Given two teams, which team is strong?
输入描述
The first line is a positive integer T(1<=T<=100) ,indicating that there are T test data.
Next, input T testdata, each test data accounts for 2 lines, and each line has 23 positive integers, which respectively represent the comprehensive quality value V(1 <= V <= 100) of 23 players of a team.
输出描述
Each test dataoutputs a line, which is the number of the strong team (numbered as 1 and 2respectively according to the order in which the teams appear).
示例1
输入:
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3
输出:
1 2
C++ 解法, 执行用时: 4ms, 内存消耗: 316K, 提交时间: 2021-10-25 18:56:47
#include <cstdio> #include <iostream> #include <algorithm> #define For(i,l,r) for(int i=l;i<=r;i++) #define ll long long using namespace std; int t,a[24],b[24]; int main(){ cin>>t; while (t--){ int f1=0,f2=0; For(i,1,23) cin>>a[i]; For(i,1,23) cin>>b[i]; sort(a+1,a+24); sort(b+1,b+24); For(i,1,23){ if (a[i]>b[i]) f1+=1; if (a[i]<b[i]) f2+=1; } if (f1>11) cout<<1<<endl; else cout<<2<<endl; } return 0; }
Python3 解法, 执行用时: 46ms, 内存消耗: 5392K, 提交时间: 2023-03-26 12:51:29
a=int(input()) for i in range(a): b=list(map(int,input().split())) c=list(map(int,input().split())) b.sort(reverse=True) c.sort(reverse=True) z1=z2=0 for j in range(23): if b[j]>c[j]: z1+=1 else: z2+=1 if z1>z2: print(1) else: print(2) b.clear() c.clear()