• Home
  • About
    • changsoooooo's Blog photo

      changsoooooo's Blog

      changsoooooo's Blog.

    • Learn More
    • Twitter
    • Facebook
    • Instagram
    • Github
    • Steam
  • 일상
  • 교육
    • 교육학
    • 정보 컴퓨터 교육
    • 임용
  • 개발
  • 잡지식
  • 한국사
  • Projects

1919(에너그램만들기)

08 Nov 2020

Reading time ~1 minute

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <list>

using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	string a, b;
	cin >> a >> b;
	int i, j;
	int er=0;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	for (i=0,j=0; i < a.length()&&j<b.length(); )
	{
		if (a.at(i)>b.at(j))
		{
			j++;
			er++;
		}
		else if (a.at(i) < b.at(j)) {
			i++;
			er++;
		}
		else
		{
			i++;
			j++;
		}
	}
	if (i < a.length()) {
		er += a.length() - i;
	}
	else
	{
		er += b.length() - j;
	}
	cout << er;

}


Share Tweet +1