Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <cstdio>
- #include <vector>
- #include <cmath>
- #include <queue>
- #include <string>
- #include <cstring>
- #include <cassert>
- #include <iomanip>
- #include <algorithm>
- #include <set>
- #include <map>
- #include <ctime>
- #include <cmath>
- #define f0(i,n) for (int i = 0; i < int(n); i++)
- #define fs first
- #define sc second
- #define sz(v) int(v.size())
- #define pb push_back
- #define mp make_pair
- #define y1 ________y1
- template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
- template<typename X> inline X sqr(const X& a) { return a * a; }
- typedef long long li;
- typedef long double ld;
- using namespace std;
- int a[5000 + 13] = {0};
- int b[5000 + 13];
- int c[5000 + 13]= {0};
- bool fl;
- int main()
- {
- int n;
- cin >> n;
- int tmp;
- f0(i,n)
- {
- cin >> a[i] >> b[i];
- if (a[i] != b[i])
- {
- ++c[a[i]];
- ++c[b[i]];
- }
- if (a[i] == b[i])
- {
- ++c[a[i]];
- }
- tmp = max(tmp,max(a[i],b[i]));
- }
- int max1 = 0, max2 = 0;
- f0(i,tmp)
- {
- if (c[i] >= max1)
- {
- max2 = max1;
- max1 = c[i];
- continue;
- }
- if (c[i] > max2) max2 = max1;
- }
- int Max = max1 + max2;
- int ans = n * 2 - Max;
- cout << ans << endl;
- return 0;
- //system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement