intmain() { // [mb, k - ma] int n, k, ma, mb; std::cin >> n >> k >> ma >> mb; if (ma + mb > k) returnputs("0"), 0; std::vector<int> a(n), b(n), id(n); for (int &x : a) scanf("%d", &x); for (int &x : b) scanf("%d", &x); LL sum = 0; for (int &x : a) sum += x; MCMFGraph<int, LL> mcmf(n - k + 2, n * 5); mcmf.S = n - k + 2, mcmf.T = n - k + 1; mcmf.add(n - k + 2, 0, k - ma, 0); for (int i = 0; i < n; ++ i) id[i] = mcmf.idx, mcmf.add(std::max(i - k + 1, 0), std::min(n - k, i) + 1, 1, b[i] - a[i]); for (int i = 0; i <= n - k; ++ i) mcmf.add(i, i + 1, k - mb - ma, 0); std::cout << sum + mcmf.solve().second << std::endl; LL cur = 0; for (int x = 0; x < n; ++ x) { int i = id[x]; putchar(mcmf.edg[i].f ? 'S' : 'E'); cur += !mcmf.edg[i].f * (b[x] - a[x]); } // std::cout << '\n' << cur << std::endl; return0; }