1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 5 using namespace std; 6 const int maxn = 10005; 7 double a[maxn]; 8 int b[maxn]; 9 double c[maxn]; 10 11 int main(){ 12 ios::sync_with_stdio(false); 13 int k; 14 cin >> k; 15 int x; 16 double y; 17 int Max = 0; 18 for (int i = 1; i <= k; i++){ 19 cin >> x >> y; 20 a[x] += y; 21 if (Max < x) 22 Max = x; 23 } 24 int k1; 25 cin >> k1; 26 for (int i = 1; i <= k1; i++){ 27 cin >> x >> y; 28 a[x] += y; 29 if (Max < x) 30 Max = x; 31 } 32 int ans = 0; 33 for (int i = Max; i >= 0; i--){ 34 if (a[i] == 0) continue; 35 b[ans] = i; 36 c[ans++] = a[i]; 37 } 38 cout << ans; 39 for (int i = 0; i < ans; i++){ 40 printf(" %d %.1lf", b[i], c[i]); 41 //cout << " " << b[i] << " " << c[i]; 42 } 43 //最后一行没有空格(包括换行) 44 //cout << endl; 45 system("pause"); 46 return 0; 47 }