⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1316.cpp

📁 平时acm训练时ac的源代码
💻 CPP
字号:
//1316

#include <iostream>
#include <string>
#include <memory>

using namespace std;

const int e5 = 100000;
const int e4 = 10000;
const int e3 = 1000;
const int e2 = 100;
const int e1 = 10;

string str;
int list1[1000000];
int list2[100000];
int list3[10000];
int list4[1000];
int list5[100];
int list6[10];
int mid, i1, i2, i3, i4, i5, i6, sellcnt;
__int64 res;
double tmp;

int main(void)
{
	res = 0;
	cin>>str;
	memset(list1, 0, sizeof(list1));
	memset(list2, 0, sizeof(list2));
	memset(list3, 0, sizeof(list3));
	memset(list4, 0, sizeof(list4));
	memset(list5, 0, sizeof(list5));
	memset(list6, 0, sizeof(list6));
	while ('Q'!=str[0])
	{
		switch (str[0])
		{
		case 'B':
			{
				cin>>tmp;
				mid = int(tmp*1e2+0.1)-1;
				list6[mid/e5] += 1;
				list5[mid/e4] += 1;
				list4[mid/e3] += 1;
				list3[mid/e2] += 1;
				list2[mid/e1] += 1;
				list1[mid] += 1;
				break;
			}
		case 'D':
			{
				cin>>tmp;
				mid = int(tmp*1e2+0.1)-1;
				list6[mid/e5] -= 1;
				list5[mid/e4] -= 1;
				list4[mid/e3] -= 1;
				list3[mid/e2] -= 1;
				list2[mid/e1] -= 1;
				list1[mid] -= 1;
				break;
			}
		case 'S':
			{
				cin>>tmp>>sellcnt;
				mid = int(tmp*1e2+0.1)-1;
				for (i6=9; i6>=0 && (i6+1)*e5>mid && sellcnt>0; i6--)
				{
					if (0==list6[i6])
					{
						continue;
					}
					if (i6*e5>=mid)
					{
						res += list6[i6];
						sellcnt -= list6[i6];
						if (sellcnt<0)
						{
							res += sellcnt;
						}
						continue;
					}
					for (i5=9; i5>=0 && i6*e5+(i5+1)*e4>mid && sellcnt>0; i5--)
					{
						if (0==list5[i6*e1+i5])
						{
							continue;
						}
						if (i6*e5+i5*e4>=mid)
						{
							res += list5[i6*e1+i5];
							sellcnt -= list5[i6*e1+i5];
							if (sellcnt<0)
							{
								res += sellcnt;
							}
							continue;
						}
						for (i4=9; i4>=0 && i6*e5+i5*e4+(i4+1)*e3>mid && sellcnt>0; i4--)
						{
							if (0==list4[i6*e2+i5*e1+i4])
							{
								continue;
							}
							if (i6*e5+i5*e4+i4*e3>=mid)
							{
								res += list4[i6*e2+i5*e1+i4];
								sellcnt -= list4[i6*e2+i5*e1+i4];
								if (sellcnt<0)
								{
									res += sellcnt;
								}
								continue;
							}
							for (i3=9; i3>=0 && i6*e5+i5*e4+i4*e3+(i3+1)*e2>mid && sellcnt>0; i3--)
							{
								if (0==list3[i6*e3+i5*e2+i4*e1+i3])
								{
									continue;
								}
								if (i6*e5+i5*e4+i4*e3+i3*e2>=mid)
								{
									res += list3[i6*e3+i5*e2+i4*e1+i3];
									sellcnt -= list3[i6*e3+i5*e2+i4*e1+i3];
									if (sellcnt<0)
									{
										res += sellcnt;
									}
									continue;
								}
								for (i2=9; i2>=0 && i6*e5+i5*e4+i4*e3+i3*e2+(i2+1)*e1>mid && sellcnt>0; i2--)
								{
									if (0==list2[i6*e4+i5*e3+i4*e2+i3*e1+i2])
									{
										continue;
									}
									if (i6*e5+i5*e4+i4*e3+i3*e2+i2*e1>=mid)
									{
										res += list2[i6*e4+i5*e3+i4*e2+i3*e1+i2];
										sellcnt -= list2[i6*e4+i5*e3+i4*e2+i3*e1+i2];
										if (sellcnt<0)
										{
											res += sellcnt;
										}
										continue;
									}
									for (i1=9; i1>=0 && i6*e5+i5*e4+i4*e3+i3*e2+i2*e1+i1>=mid && sellcnt>0; i1--)
									{
										if (list1[i6*e5+i5*e4+i4*e3+i3*e2+i2*e1+i1]>0)
										{
											res += list1[i6*e5+i5*e4+i4*e3+i3*e2+i2*e1+i1];
											sellcnt -= list1[i6*e5+i5*e4+i4*e3+i3*e2+i2*e1+i1];
											if (sellcnt<0)
											{
												res += sellcnt;
											}
										}
									}
								}
							}
						}
					}
				}
				break;
			}
		}
		cin>>str;
	}
	printf("%I64d.", res/100);
	res %= 100;
	if (res<10)
	{
		printf("0");
	}
	printf("%I64d\n", res);
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -