QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#587964#9370. Gambling on Choosing RegionalseweweWA 121ms9984kbC++14933b2024-09-24 23:02:352024-09-24 23:02:35

Judging History

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

  • [2024-09-24 23:02:35]
  • 评测
  • 测评结果:WA
  • 用时:121ms
  • 内存:9984kb
  • [2024-09-24 23:02:35]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int max_n=1e5+10;
struct s
{
	int id,w,res;
	string name;
};
s va[max_n];
int a[max_n];

bool cmp1(s v1,s v2)
{
	return v1.w>v2.w;
}

bool cmp2(s v1,s v2)
{
	return v1.id<v2.id;
}

void solve()
{
	int n,k;
	cin>>n>>k;
	for (int i=1;i<=k;i++)
	cin>>a[i];
	for (int i=1;i<=n;i++)
	{
		va[i].id=i;
		int value;
		string name;
		cin>>value>>name;
		va[i].name=name;
		va[i].w=value;
	}
	int value=a[1];
	
	map <string,int> m,temp;
	sort(va+1,va+n+1,cmp1);
	
	int res=0;
	for (int i=1;i<=n;i++)
	{
		string name=va[i].name;
		
		if (m[name]<value)
		{
			res++;
			m[name]++;
		}
		
		va[i].res=res;
		
	}
	sort(va+1,va+n+1,cmp2);
	for (int i=1;i<=n;i++)
	{
		cout<<va[i].res<<endl;
	}
	return ;
}

signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 9092kb

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: 2ms
memory: 9796kb

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
Wrong Answer
time: 121ms
memory: 9984kb

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:

94907
15938
51981
98470
83677
32345
52328
31696
44705
3240
40243
6189
77801
72454
67601
44666
14040
74317
35039
65000
35508
19143
56593
9110
54778
64546
18367
1344
25930
75155
39938
5884
87260
86787
23307
65666
19346
38658
1131
26532
93599
99215
23152
92308
46948
75923
66463
91436
44056
54275
24935
...

result:

wrong answer 1st lines differ - expected: '1000', found: '94907'