直接map模拟即可,隻是輸出格式簡直天坑。cin cout會逾時,map每次用完要清理(喵的,題意敢不敢說清楚啊)
// Problem#: 1486
// Submission#: 3178003
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include<cstdio>
#include<iostream>
#include<map>
using namespace std;
int main() {
int test;
int temp;
map<int, int> myMap;
bool flag = false;
while (scanf("%d", &test) != EOF) {
if (flag)
printf("\n");
flag = true;
while (test--) {
scanf("%d", &temp);
myMap[temp]++;
}
map<int, int>::iterator it = myMap.begin();
for (; it != myMap.end(); it++)
printf("%d %d\n", it->first, it->second);
myMap.clear();
}
}