```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 100;
int n, s, p[N][N / 10], a[N], b[N], f[N][N / 10], from[N][N / 10];
//unordered_map<int, int> mp;
signed main(){
ios :: sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n >> s;
for(int i = 1; i <= n; ++i){
cin >> a[i] >> b[i];
p[i][a[i]] = 'H';
p[i][b[i]] = 'T';
}
f[0][0] = 1;
for(int i = 1; i <= n; ++i){
for(int j = s; j >= a[i]; --j)
if(f[i - 1][j - a[i]]){
from[i][j] = j - a[i];
f[i][j] = 1;
}
for(int j = s; j >= b[i]; --j)
if(f[i - 1][j - b[i]]){
from[i][j] = j - b[i];
f[i][j] = 1;
}
//for(int j = 0; j <= s; ++j)
//if(f[i][j]) cout << j << ' ';
//cout << '\n';
}
if(f[n][s]){
cout << "Yes\n";
string ans = "";
int cur = s;
for(int i = n; i; --i){
ans += char(p[i][cur - from[i][cur]]);
cur = from[i][cur];
}
cout << string(ans.rbegin(), ans.rend()) << '\n';
}else cout << "No\n";
return 0;
}
by Fat_Fish @ 2022-10-01 22:09:53
@[Fat_Fish](/user/238885) 你确定你数组没开小?
by Ginger_he @ 2022-10-01 22:14:02
@[Fat_Fish](/user/238885) 你是不是把数组的两个维度大小开反了
by DitaMirika @ 2022-10-01 22:15:36
```
100 4897
94 63
76 89
6 83
74 24
1 4
71 57
64 99
46 50
49 8
34 13
8 83
96 34
57 3
41 24
92 70
84 48
80 44
55 57
92 57
88 13
46 48
33 78
60 41
57 48
29 58
88 22
47 78
41 50
2 86
29 33
69 84
85 29
20 9
94 49
84 10
82 56
77 81
39 78
1 3
70 5
71 22
36 74
27 65
76 51
57 16
41 30
25 96
52 61
10 82
92 96
84 84
97 27
41 70
46 65
8 30
35 24
58 6
21 53
24 75
61 52
52 51
32 1
19 1
42 23
96 57
36 16
1 23
46 53
69 83
62 77
57 71
96 52
1 95
5 64
64 83
26 95
99 75
14 36
82 47
33 56
46 94
9 25
8 53
6 42
5 1
58 90
10 79
80 87
63 54
36 81
2 55
19 28
61 87
41 96
89 61
48 10
26 3
59 66
97 5
94 19
```
提供一组把我卡掉的大样例
by QQ82272760 @ 2022-10-01 22:15:38
数组开大就过了?
by QQ82272760 @ 2022-10-01 22:17:08
@[QQ82272760](/user/189682)
@[SweetOrangeOvO](/user/236862)
@[Ginger_he](/user/379058)
已过, 谢谢各位大佬
------------
~~这道题犯了好多弱智错误~~
by Fat_Fish @ 2022-10-01 22:20:02