diff options
author | Raphael McSinyx <vn.mcsinyx@gmail.com> | 2017-02-21 21:09:39 +0700 |
---|---|---|
committer | Raphael McSinyx <vn.mcsinyx@gmail.com> | 2017-02-21 21:09:39 +0700 |
commit | 7d19f480637e9e880b98dabfbcf8e885b0a2d3b9 (patch) | |
tree | fa52914a2e58bc13570839fa297be05b7b7616bf /others/volume1/077.pas | |
parent | f2d4bc6b7c302dee2d84a3acf84b83b5a98c45fa (diff) | |
download | cp-7d19f480637e9e880b98dabfbcf8e885b0a2d3b9.tar.gz |
Update others/volume1
Diffstat (limited to 'others/volume1/077.pas')
-rw-r--r-- | others/volume1/077.pas | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/others/volume1/077.pas b/others/volume1/077.pas new file mode 100644 index 0000000..2d13a4d --- /dev/null +++ b/others/volume1/077.pas @@ -0,0 +1,59 @@ +uses clib; + +var + n, m: int32; + a, b, c: array of int64; + i, j: int64; + +begin + readln(n, m); + setlength(a, n); + repeat + dec(n); + read(a[n]) + until n = 0; + qsort(a); + setlength(b, m); + repeat + dec(m); + read(b[m]) + until m = 0; + qsort(b); + + setlength(c, 0); + for i in a do + if (bsearch(b, i) > -1) and + ((length(c) = 0) or (c[length(c) - 1] < i)) then + begin + setlength(c, length(c) + 1); + c[length(c) - 1] := i + end; + + for i in c do + begin + dec(n, 2); + j := bsearch(a, i); + for m := j downto 0 do + if a[m] = i then + inc(n) + else + break; + for m := j to length(a) - 1 do + if a[m] = i then + inc(n) + else + break; + j := bsearch(b, i); + for m := j downto 0 do + if b[m] = i then + inc(n) + else + break; + for m := j to length(b) - 1 do + if b[m] = i then + inc(n) + else + break + end; + writeln(n) +end. |