Codeforces Round #294 (Div. 2) B. A and B and Compilation Errors

 

题目地址:http://codeforces.com/contest/519/problem/B

 1 /*  2  题意:三组数列,依次少一个,找出少了的两个数  3  1. 三次排序,逐个对比(如果没找到,那个数在上一个数列的末尾)  4  2. 求和做差,最简单!  5 */  6 #include <cstdio>  7 #include <algorithm>  8 #include <iostream>  9 using namespace std;  10  11 const int maxn = 1e5 + 10;  12 int a[maxn];  13 int b[maxn];  14 int c[maxn];  15  16 int main(void)  17 {  18 //freopen ("B.in", "r", stdin);  19  20 int n, x, y;  21  22 while (~scanf ("%d", &n))  23  {  24 x = y = 0;  25 for (int i=1; i<=n; ++i)  26  {  27 scanf ("%d", &a[i]);  28  }  29 sort (a+1, a+1+n);  30 for (int i=1; i<=n-1; ++i)  31  {  32 scanf ("%d", &b[i]);  33  }  34 sort (b+1, b+1+n-1);  35 for (int i=1; i<=n-1; ++i)  36  {  37 if (a[i] == b[i]) continue;  38 else  39  {  40 x = a[i];  41 break;  42  }  43  }  44 if (x == 0) x = a[n];  45 for (int i=1; i<=n-2; ++i)  46  {  47 scanf ("%d", &c[i]);  48  }  49 sort (c+1, c+1+n-2);  50 for (int i=1; i<=n-2; ++i)  51  {  52 if (b[i] == c[i]) continue;  53 else  54  {  55 y = b[i];  56 break;  57  }  58  }  59 if (y == 0) y = b[n-1];  60 printf ("%d\n%d\n", x, y);  61  62  }  63  64 return 0;  65 }  66  67 /*  68 #include <cstdio>  69 #include <algorithm>  70 #include <iostream>  71 using namespace std;  72  73 const int maxn = 1e5 + 10;  74 int a[maxn];  75 int b[maxn];  76 int c[maxn];  77 int suma, sumb, sumc;  78  79 int main(void)  80 {  81  //freopen ("B.in", "r", stdin);  82  83  int n;  84  85  while (~scanf ("%d", &n))  86  {  87  suma = sumb = sumc = 0;  88  for (int i=1; i<=n; ++i)  89  {  90  scanf ("%d", &a[i]); suma += a[i];  91  }  92  for (int i=1; i<=n-1; ++i)  93  {  94  scanf ("%d", &b[i]); sumb += b[i];  95  }  96  for (int i=1; i<=n-2; ++i)  97  {  98  scanf ("%d", &c[i]); sumc += c[i];  99  } 100 101  printf ("%d\n%d\n", suma - sumb, sumb - sumc); 102  } 103 104  return 0; 105 } 106 */

 

你可能感兴趣的:(codeforces)