1100 校庆 较简单

代码

#include <iostream>
#include <cstdio>
#include <map>
#include <string>
using namespace std;

int main()
{
	int n;
	string index;
	map<string,int> mp;
	int m;
	int max1=30000000;
	int max2=30000000;
	string maxa;
	string maxb;
	int cnt=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>index;
		mp[index]=1;
	}
	cin>>m;
	for(int i=0;i<m;i++){
		cin>>index;
		if(mp.find(index)!=mp.end()){
			cnt++;
			if(max1>stoi(index.substr(6,8))){
				max1=stoi(index.substr(6,8));
				maxa=index;
			}
		}
		else{
			if(max2>stoi(index.substr(6,8))){
				max2=stoi(index.substr(6,8));
				maxb=index;
			}
		}
	}
	cout<<cnt<<endl;
	if(cnt!=0){
		cout<<maxa;
	}
	else{
		cout<<maxb;
	}
	

	return 0;
}
posted @ 2022-07-15 09:35  qwasdasd  阅读(66)  评论(0)    收藏  举报