Tepley @ 2024-11-02 21:55:10
B4049
求代码
by xC41 @ 2024-11-02 22:06:59
按题意模拟即可
by xinxin2022 @ 2024-11-02 22:07:18
//签到题
#include<bits/stdc++.h>
using namespace std;
int n,cnt,y,ans,all,rk,p[45],id[45][105],sc[45][105],w[45][105];
bool check(int now){
for(int i=1;i<=p[now];i++){
if(id[now][i]==y) return true;
}
return false;
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>p[i];
for(int j=1;j<=p[i];j++) cin>>id[i][j];
for(int j=1;j<=p[i];j++) cin>>sc[i][j];
for(int j=1;j<=p[i];j++) cin>>w[i][j];
}
cin>>y;
for(int i=1;i<=n;i++){
if(check(i)==0) continue;
rk=0,cnt=0;
sort(id[i]+1,id[i]+p[i]+1);
for(int j=1;j<=p[i];j++) if(id[i][j]==y) cnt=sc[i][j];
for(int j=1;j<=p[i];j++) if(sc[i][j]>cnt) rk++;
ans+=w[i][rk+1];
all++;
}
//cout<<ans;
if(ans%all==0) cout<<ans/all;
else{
cout<<int(ans/all)<<'+';
ans-=int(ans/all)*all;
int k=__gcd(ans,all);
ans/=k;all/=k;
cout<<ans<<'/'<<all;
}
return 0;
}