# LDU-五一假期专练（5.1）

## J - Cunning Friends

typedef int itn;
int n, m;
int eq, da, xiao;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
if (x > 2) da++;
else if (x == 2) eq++;
else xiao++;
}
if (da == 1) da--, eq++;
if (da > 1) puts("Lose");
else if (eq > 2) puts("Lose");
else if (eq == 1) puts("Win");
else {
if (xiao % 3) puts("Win");
else puts("Lose");
}
return 0;
}

/*
2 10
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
AB
ABBBBABBBB

10
*/


## F - Binary Transformations

typedef int itn;
int n;
ll a[maxn];
string s,t;
ll sum = 0,ans = 0;
vector<ll> vet;
multiset<ll> st1,st2;
bool cmp(ll a,ll b){
return a > b;
}
ll get(int x){
ll ret = 0;
ll s = sum;
int pos = x;
if(pos) st1.insert(vet[pos-1]),st2.insert(vet[pos-1]);
multiset<ll> :: iterator it1;
multiset<ll> :: reverse_iterator it2;
/// 1-> 0  big -> small
for(it2 = st1.rbegin();it2 != st1.rend();++it2){
s -= *(it2);
ret += s;
}
for(it1 = st2.begin();it1 != st2.end(); ++ it1){
s += *(it1);
ret += s;
}
return ret;
}
int main() {
cin >> n;
for(int i=1;i<=n;i++) cin >> a[i];
cin >> s;
cin >> t;
s = "#" + s;
t = "#" + t;
for(int i=1;i<=n;i++){
if(s[i] == '1') sum += a[i];
if(s[i] != t[i]) {
if(s[i] == '1') st1.insert(a[i]);
else st2.insert(a[i]);
}else if(s[i] == '1'){
vet.push_back(a[i]);
}
}
sort(vet.begin(),vet.end(),cmp);
int siz = vet.size();
ll ans = inf;
// cout <<"ans :  " << ans <<endl;
for(itn i=0;i<=siz;i++){
ans = min(ans,get(i));
}
cout << ans <<endl;
return 0;
}


## A - Concerts

dp

Announcement
1 <= k <= 300 1 <= n <= 10^5

dp[i][j] == dp[i][j] + dp[i-1][j-val[i]-1]

dp[i][j] == dp[i][j] + dp[i-1][j]

int n, m;
char a[maxn];
char b[maxn];
int val[30];
int dp[307][maxn];
int main() {
// n < m -> n 300 m 1e5;
cin >> n >> m;
for (itn i = 1; i <= 26; i++) val[i] = read;
cin >> a + 1;
cin >> b + 1;
for (int i = 1; i <= m; i++) { // len of b
if (a[1] == b[i])
dp[1][i] = 1;
}
for (itn i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (a[i] == b[j]) {
// 匹配成功
int t = a[i - 1] - 'A' + 1; // 'A' == 64 + 1
if (j - val[t] - 1 >= 1)
dp[i][j] += dp[i - 1][j - val[t] - 1], dp[i][j] %= mod;
}
dp[i][j] += dp[i][j - 1];
dp[i][j] %= mod;
}
}
cout << dp[n][m] % mod << endl;
return 0;
}

/*
2 10
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
AB
ABBBBABBBB

10
*/


11-18 108
03-10 803
08-06
12-12
01-28 262
04-22 55