天天看点

Sicily 1486 统计数字

直接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();
    }
}