#include //typedef //-------------------------#include #define M_PI 3.14159265358979323846 using namespace std; //conversion //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } inline int readInt() { int x; scanf("%d", &x); return x; } //typedef //------------------------------------------ typedef vector VI; typedef vector VVI; typedef vector VS; typedef pair PII; typedef pair PLL; typedef pair TIII; typedef long long LL; typedef unsigned long long ULL; typedef vector VLL; typedef vector VVLL; //container util //------------------------------------------ #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define SZ(a) int((a).size()) #define SQ(a) ((a)*(a)) #define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define SORT(c) sort((c).begin(),(c).end()) //repetition //------------------------------------------ #define FOR(i,s,n) for(int i=s;i<(int)n;++i) #define REP(i,n) FOR(i,0,n) #define MOD 1000000007 #define rep(i, a, b) for(int i = a; i < (b); ++i) #define trav(a, x) for(auto& a : x) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() typedef long long ll; typedef pair pii; typedef vector vi; const double EPS = 1E-8; #define chmin(x,y) x=min(x,y) #define chmax(x,y) x=max(x,y) class UnionFind { public: vector par; vector siz; vector maxv; UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) { for (ll i = 0; i < sz_; ++i) par[i] = i; } void init(ll sz_) { par.resize(sz_); siz.assign(sz_, 1LL); for (ll i = 0; i < sz_; ++i) par[i] = i; } ll root(ll x) { while (par[x] != x) { x = par[x] = par[par[x]]; } return x; } bool merge(ll x, ll y) { x = root(x); y = root(y); if (x == y) return false; if (siz[x] < siz[y]) swap(x, y); siz[x] += siz[y]; par[y] = x; return true; } bool issame(ll x, ll y) { return root(x) == root(y); } ll size(ll x) { return siz[root(x)]; } }; ll mod_pow(ll x, ll n, ll mod = MOD){ if(n <= 0) return 1; ll res = 1; while(n){ if(n&1) res = (res * x)%mod; res %= mod; x = x * x %mod; n >>= 1; } return res; } #define SIEVE_SIZE 5000000+10 bool sieve[SIEVE_SIZE]; void make_sieve(){ for(int i=0; i node, lazy; public: LazySegmentTree(vector v) { int sz = (int)v.size(); n = 1; while(n < sz) n *= 2; node.resize(2*n-1); lazy.resize(2*n-1, 0); for(int i=0; i=0; i--) node[i] = node[i*2+1] + node[i*2+2]; } void eval(int k, int l, int r) { if(lazy[k] != 0) { node[k] += lazy[k]; if(r - l > 1) { lazy[2*k+1] += lazy[k] / 2; lazy[2*k+2] += lazy[k] / 2; } lazy[k] = 0; } } void add(int a, int b, ll x, int k=0, int l=0, int r=-1) { if(r < 0) r = n; eval(k, l, r); if(b <= l || r <= a) return; if(a <= l && r <= b) { lazy[k] += (r - l) * x; eval(k, l, r); } else { add(a, b, x, 2*k+1, l, (l+r)/2); add(a, b, x, 2*k+2, (l+r)/2, r); node[k] = node[2*k+1] + node[2*k+2]; } } ll getsum(int a, int b, int k=0, int l=0, int r=-1) { if(r < 0) r = n; eval(k, l, r); if(b <= l || r <= a) return 0; if(a <= l && r <= b) return node[k]; ll vl = getsum(a, b, 2*k+1, l, (l+r)/2); ll vr = getsum(a, b, 2*k+2, (l+r)/2, r); return vl + vr; } }; int const INF = INT_MAX; struct SegmentTree { private: int n; vector node; public: SegmentTree(vector v) { int sz = v.size(); n = 1; while(n < sz) n *= 2; node.resize(2*n-1, INF); for(int i=0; i=0; i--) node[i] = min(node[2*i+1], node[2*i+2]); } void update(int x, int val) { x += (n - 1); node[x] = val; while(x > 0) { x = (x - 1) / 2; node[x] = min(node[2*x+1], node[2*x+2]); } } int getmin(int a, int b, int k=0, int l=0, int r=-1) { if(r < 0) r = n; if(r <= a || b <= l) return INF; if(a <= l && r <= b) return node[k]; int vl = getmin(a, b, 2*k+1, l, (l+r)/2); int vr = getmin(a, b, 2*k+2, (l+r)/2, r); return min(vl, vr); } }; using Weight = int; using Flow = int; struct Edge { int src, dst; Weight weight; Flow cap; Edge() : src(0), dst(0), weight(0) {} Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {} }; using Edges = std::vector; using Graph = std::vector; using Array = std::vector; using Matrix = std::vector; void add_edge(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); g[b].emplace_back(b, a, w); } void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); } // template class basic_stopwatch: T { // typedef typename T BaseTimer; // public: // explicit basic_stopwatch(bool start); // explicit basic_stopwatch(char const* activity = "Stopwatch", bool start = true); // basic_stopwatch(std::ostream& log, char const* activity = "Stopwatch", bool start = true); // basic_stopwatch(); // unsigned LapGet() const; // bool IsStarted() const; // unsigned Show(char const* event = "show"); // unsigned Start(char const* event_name = "start"); // unsigned Stop(char const* event_name = "stop"); // private: // char const* m_activity; // unsigned m_lap; // std::ostream& m_log; // }; // #include // using namespace std::chrono; // class TimerBase { // public: // // タイマをクリアする // TimerBase(): m_start(system_clock::time_point::min()) {} // void Clear(){ // m_start = system_clock::time_point::min(); // } // bool IsStarted() const { // return (m_start.time_since_epoch() != system_clock::duration(0)); // } // void Start() { // m_start = system_clock::now(); // } // unsigned long GetMs(){ // if(IsStarted()) { // system_clock::duration diff; // diff = system_clock::now() - m_start; // return (unsigned)(duration_cast(diff).const(); // } // return 0; // } // private: // system_clock::time_point m_start; // }; //二部マッチング struct BipartiteMatching { vector< vector< int > > graph; vector< int > match, alive, used; int timestamp; BipartiteMatching(int n) : graph(n), alive(n, 1), used(n, 0), match(n, -1), timestamp(0) {} void add_edge(int u, int v) { graph[u].push_back(v); graph[v].push_back(u); } bool dfs(int idx) { used[idx] = timestamp; for(auto &to : graph[idx]) { int to_match = match[to]; if(alive[to] == 0) continue; if(to_match == -1 || (used[to_match] != timestamp && dfs(to_match))) { match[idx] = to; match[to] = idx; return true; } } return false; } int bipartite_matching() { int ret = 0; for(int i = 0; i < graph.size(); i++) { if(alive[i] == 0) continue; if(match[i] == -1) { ++timestamp; ret += dfs(i); } } return ret; } void output() { for(int i = 0; i < graph.size(); i++) { if(i < match[i]) { cout << i << "-" << match[i] << endl; } } } }; int main() { cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15); ll n, m, K; cin >> n >> m >> K; char c; cin >> c; vector a(m), b(n); ll sum = 0; REP(i,m) { cin >> a[i]; } sort(all(a)); REP(i,n) { cin >> b[i]; } sort(all(b)); if(c == '+'){ ll ans = 0; for(int i=0; i