UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#171359#999. 上网统计heyuzhen1002ms1368kbC++457b2023-06-22 21:55:422023-06-22 21:55:43

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
struct node{
	ll id,num;
}b[100005];
ll n,a;
bool cmp(node a,node b){
	if(a.num == b.num)
		return a.id < b.id;
	return a.num > b.num;
}
int main(){
	cin >>n;
	for(ll i = 0;i <= 10000;i++)
		b[i].id = i;
	while(n--){
		cin >> a;
		b[a].num++;
	}sort(b,b + 10001,cmp);
	for(ll i = 0;i < 10;i++)
		if(b[i].num)cout << b[i].id << " " <<b[i].num << "\n";
	return 0;
}


详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 33
Accepted
time: 0ms
memory: 1368kb

input:

27
22 22 18 1 19 19 13 3 16 10 5 17 4 9 13 19 6 24 15 15 12 13 16 1 9 1 13

output:

13 4
1 3
19 3
9 2
15 2
16 2
22 2
3 1
4 1
5 1

result:

ok 10 lines

Test #2:

score: 33
Accepted
time: 1ms
memory: 1368kb

input:

194
169 31 81 147 67 175 55 123 15 54 59 102 108 181 7 188 33 16 142 107 182 37 119 141 70 164 35 50...

output:

7 4
50 4
171 4
2 3
21 3
26 3
35 3
53 3
59 3
67 3

result:

ok 10 lines

Test #3:

score: 33
Accepted
time: 1ms
memory: 1364kb

input:

793
156 215 525 581 725 522 339 610 520 722 441 425 344 685 219 219 337 530 689 98 545 389 161 617 5...

output:

62 5
454 5
314 4
328 4
399 4
504 4
527 4
532 4
689 4
789 4

result:

ok 10 lines