比赛 EYOI与SBOI开学欢乐赛2nd 评测结果 AWWWW
题目名称 个人所得税 最终得分 20
用户昵称 lihaoze 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2022-09-02 20:15:14
显示代码纯文本
#include <bits/stdc++.h> 

const int N = 50010;

int n;
int a[N][13], b[N][13];

#define CALC(v, rate) if (bat >= v) bat -= v, res += v * rate; \
					  else res += bat * rate, bat = 0;

double calc_pay(int x) {
	double res = 0;
	double bat = x - 800;
	CALC(500, 0.05) CALC(1500, 0.10)
	CALC(3000, 0.15) CALC(15000, 0.20)
	CALC(20000, 0.25) CALC(20000, 0.30)
	CALC(20000, 0.35) CALC(20000, 0.40)
	res += bat * 0.45;
	return res;
}

double calc_inc(int x) {
	double res = 0;
	double bat;
	if (x <= 4000) bat = x - 800;
	else bat = 1.0 * x - x * 0.20;
	CALC(20000, 0.20) CALC(30000, 0.30)
	res += bat * 0.40;
	return res;
}

int main() {
	freopen("personaltax.in", "r", stdin);
	freopen("personaltax.out", "w", stdout);
	std::cin >> n;
	double ans = 0;
	char op[10];
	int id, mon, day, inc;
	while (scanf("%s %d %d/%d %d", op, &id, &mon, &day, &inc) == 5) {
		if (op[0] == 'P') 
			a[id][mon] += inc;
		else 
			ans += calc_inc(inc);
	}
	for (int i = 1; i <= n; ++ i) 
		for (int j = 1; j <= 12; ++ j) 
			if (a[i][j]) ans += calc_pay(a[i][j]);
	printf("%.2lf", ans);
	return 0;
}