求助 H
  • 板块学术版
  • 楼主Quartz_Blocks
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/10/18 21:22
  • 上次更新2024/10/18 23:27:13
查看原帖
求助 H
1059176
Quartz_Blocks楼主2024/10/18 21:22
#include <bits/stdc++.h>
using namespace std;
struct stu{
	int id,sc;
};
struct node{
	int p;
	stu s[110];
	int w[110];
}a[45];
int gcd(int a,int b){return b == 0 ? a : gcd(b, a % b);}
int n;
void func(int &n,int &d){
	int c = gcd(n, d);
	n /= c;
	d /= c;
}
void print(int n,int d) {
	int w = n/d;
	int f = n%d;
	if(w > 0){
		cout << w;
		if(f > 0){
			cout << "+";
		}
	}
	if(f > 0){
		cout << f << "/" << d;
	}
	if(w == 0 && f == 0){
		cout << "0";
	}
	return;
}
void prt(int c,int a[]){
	int s = 0;
	for(int i = 1;i <= c;i++){
		if(a[i] == 0) c--;
		s += a[i];
	}
	int n = s;
	int d = c;
	func(n, d);
//	cout << n << ' ' << d << ' ' << s << ' ' << c << endl;
	if(d == 1){
		cout << n;
	}else{
		print(n,d);
	}
}
int num;
bool cmp(stu x,stu y){
	return x.sc > y.sc;
}
bool cmp2(stu x,stu y){
	return x.id < y.id;
}
int score[45];
int main(){
	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> a[i].p;
		for(int j = 1;j <= a[i].p;j++) cin >> a[i].s[j].id;
		sort(a[i].s+1,a[i].s+a[i].p+1,cmp2);
		for(int j = 1;j <= a[i].p;j++) cin >> a[i].s[j].sc;
		for(int j = 1;j <= a[i].p;j++) cin >> a[i].w[j];
	}
	cin >> num;
	int t[110];
	
	

	for(int i = 1;i <= n;i++){
		memset(t,0,sizeof(t));
		sort(a[i].s+1,a[i].s+a[i].p+1,cmp);
		int p = 0,cnt = 0;
		for(int j = 1;j <= a[i].p;j++){
			if(a[i].s[j].sc != a[i].s[j-1].sc){
				p++;
				t[j] = p+cnt;
				cnt = 0;
				

			}else{
				t[j] = p;
				cnt++;
			}
		}
//		cout << "t";
//		cout << endl;
//		for(int j = 1;j <= a[i].p;j++) cout << t[j] << endl;
//		cout << endl;
//		for(int j = 1;j <= a[i].p;j++){
//			cout << a[i].s[j].id << ' ' << a[i].s[j].sc << endl;
//			
//		}
		for(int j = 1;j <= a[i].p;j++){
//			cout << "\n--- "<< a[i].s[j].id << ' ' << num << ' ' << t[j] << ' ' << j<< endl;
			if(a[i].s[j].id == num){
//				cout << "finded\n" << a[i].w[t[j]];
				score[i] = a[i].w[t[j]];
			}
		}
	}
//	cout << endl;
//	for(int i = 1;i <= n;i++) cout << score[i] << '\n';
//	cout << endl;
	prt(n,score);
	
	return 0;
}
2024/10/18 21:22
加载中...