QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#582420#9370. Gambling on Choosing Regionalsorange_but_juiceRE 1ms10104kbC++141.0kb2024-09-22 16:21:272024-09-22 16:21:27

Judging History

你现在查看的是最新测评结果

  • [2024-09-22 16:21:27]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:10104kb
  • [2024-09-22 16:21:27]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

int read(){int x;scanf("%d",&x);return x;}

const int B=1e6+10;
const int inf=0x3f3f3f3f;
int n,m;
int x=inf;
int sum[12][B];
map<string,int>mp;
int tot;
int num;
struct node
{
	int x,id;
}a[B],b[B];
int c[B];
int cmp(node a,node b)
{
	return a.x>b.x;
}
int main()
{
	cin>>n>>m;
	for (int i=1;i<=m;i++)
	{
		int c=read();
		x=min(x,c);
	}
	for (int i=1;i<=n;i++)
	{
		a[i].x=read();
		string c;
		cin>>c;
		if (mp[c]==0) 
		{
			mp[c]=++num;
		}
		a[i].id=mp[c];
		b[i]=a[i];
	}
	sort(a+1,a+1+n,cmp);
	for (int i=1;i<=n;i++) c[i]=a[i].x;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=num;j++)
		{
			sum[j][i]=sum[j][i-1];
			if (a[i].id==j) sum[j][i]+=1;
		}
	}
	for (int i=1;i<=n;i++)
	{
		int l=1,r=n;
		int w=0;
		while (l<=r)
		{
			int mid=l+r>>1;
			if (b[i].x<=c[mid])
			{
				w=mid;
				l=mid+1;
			} 
			else r=mid-1;
		}
		int cc=0;
		int ok=0;
		for (int j=1;j<=num;j++)
		{
			cc+=min(x,sum[j][w]);
		}
		cout<<cc<<endl;
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 9784kb

input:

5 3
1 2 3
100 THU
110 PKU
95 PKU
105 THU
115 PKU

output:

2
1
2
2
1

result:

ok 5 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 10104kb

input:

5 2
2 3
100 THU
110 PKU
95 PKU
105 THU
115 PKU

output:

4
2
4
3
1

result:

ok 5 lines

Test #3:

score: -100
Runtime Error

input:

100000 100000
57148 51001 13357 71125 98369 67226 49388 90852 66291 39573 38165 97007 15545 51437 89611 41523 27799 15529 16434 44291 47134 90227 26873 52252 41605 21269 9135 55784 70744 17563 79061 73981 70529 35681 91073 52031 23811 79501 1607 46365 76868 72137 71041 29217 96749 46417 40199 55907 ...

output:


result: