Browse Source

...

master^2
nwerc-082 5 years ago
parent
commit
ad2e8c1c76
  1. 38
      F.cpp
  2. 29
      F.py

38
F.cpp

@ -0,0 +1,38 @@
#include <algorithm>
#include <functional>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
long f(vector<long>& l)
{
long m = 0; set<long, greater<long>> s = {0};
for(auto x : l) {
// cerr << "x = " << x << endl;
if (s.count(x) == 0) {
m = max(m, min(*s.begin(), x));
s.insert(x);
} else {
s.erase(x);
m = max(m, min(*s.begin(), x));
}
// cerr << "m = " << m << endl;
}
return m;
}
int main()
{
long n; cin >> n; vector<long> l1(n), l2(n);
for (long i = 0; i < n; ++i) cin >> l1[i];
for (long i = 0; i < n; ++i) cin >> l2[i];
set<long> s2(begin(l2), end(l2));
set<long, greater<long>> s; vector<long> l1_, l2_;
for (auto x : l1) if (s2.count(x) == 1) s.insert(x);
for (auto x : l1) if (s.count(x) == 0) l1_.push_back(x);
for (auto x : l2) if (s.count(x) == 0) l2_.push_back(x);
long m = *s.begin();
cout << max(m, max(f(l1_), f(l2_))) << endl;
}

29
F.py

@ -0,0 +1,29 @@
MOVED_TO_CPP
from __future__ import print_function
import sys
def f(l):
m, s, ms = 0, set(), 0
for x in l:
if x not in s:
s.add(x)
ms = max(x, ms)
else:
s.remove(x)
ms = ...
if ms > x:
m = max(m, x)
else:
m = max(m, ms)
return m
n = int(sys.stdin.readline())
l1 = map(int, sys.stdin.readline().split())
l2 = map(int, sys.stdin.readline().split())
s2 = set(l2)
s = [ x for x in l1 if x in s2 ]
l1 = [ x for x in l1 if x not in s ]
l2 = [ x for x in l2 if x not in s ]
m = max(s)
print(max(m, max(f(l1), f(l2))))
Loading…
Cancel
Save