Codeforces Round #294 (Div. 2) -- B. A and B and Compilation Errors
B. A and B and Compilation Errorstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayedNCompilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.
However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared-the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike your other programming ages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.
Can you help B find out exactly what two errors he corrected?
Input
The first line of the input contains integerN(3? ≤?N? ≤? (105)-the initial number of compilation errors.
The second line containsNSpace-separated integersA1 ,?A2 ,?...,?AN(1? ≤?AI? ≤? (109)-the errors the compiler displayed for the first time.
The third line containsN? -? 1 space-separated integersB1 ,?B2 ,?...,?BN? -? 1-the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string limit t for exactly one.
The fourth line containsN? -? 2 space-separated integersBytes1 ,?Bytes2 ,?...,?BytesN? -? 2-the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line limit t for exactly one.
Output
Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.
Sample test (s) input
51 5 8 123 7123 7 5 15 1 7
Output
8123
Input
61 4 3 3 5 73 7 5 4 34 3 7 5
Output
13
Note
In the first test sample B first corrects the error number 8, then the error number 123.
In the second test sample B first corrects the error number 1, then the error number 3. note that if there are multiple errors with the same number, B can correct only one of them in one step.
Idea: Sort them down and compare them one by one. These questions are smooth.
AC code:
#include
#include
#include
#include #include
using namespace std;int a[100005];int b[100005];int c[100005];int main() {int n;while(scanf("%d", &n) != EOF) {for(int i = 0; i < n; i++) scanf("%d", &a[i]);for(int i = 0; i < n - 1; i++) scanf("%d", &b[i]);for(int i = 0; i < n - 2; i++) scanf("%d", &c[i]);sort(a, a + n);sort(b, b + n - 1);sort(c, c + n - 2);for(int i = 0; i < n; i++)if(a[i] != b[i]) {printf("%d\n", a[i]); break;}for(int i = 0; i < n - 1; i++) if(b[i] != c[i]) {printf("%d\n", b[i]); break;}}return 0;}