1 solutions
-
1
#include <bits/stdc++.h> using namespace std; #define endl "\n" #define ll int //下面代码中的ll表示int #define N 100000+5 int x(ll a[], ll b[], ll n) { int ans = 0, al = 1, bl = 1, a2 = n, b2 = n; while (al <= a2) { if (a[al] > b[bl] ) { //上等马比较 ans += 2; al++; bl++; } else if (a[a2] > b[b2]) { //下等马比较 ans += 2; a2 --; b2 --; } else if (a[al] <= b[bl]) { //上下等马都比不过时用下等马去比上等马 ans += a[al] == b[b2]; //a[al]==b[b2]则返回1否则返回0 al++, b2 --; } } return ans; } int main() { // cin.tie(0); // cout.tie(0); ll n, sum1[N], sum2[N], s; ll s1 = 0, s2 = 0; cin >> n; for (int i = 1; i <= n; i++) cin >> sum1[i]; for (int i = 1; i <= n; i++) cin >> sum2[i]; sort(sum1 + 1, sum1 + n + 1);//由小到大排序 sort(sum2 + 1, sum2 + n + 1);//由小到大排序 cout << x(sum1, sum2, n) << " " << 2*n - x(sum2, sum1, n);//总分为2*n return 0; }
Information
- ID
- 6995
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- # Submissions
- 166
- Accepted
- 10
- Uploaded By