###A.Glutton Takahashi
/* ʕ•̀ ω • ʔ *˘︶˘*).。.:*♡ (∗ᵒ̶̶̷̀ω˂̶́∗)੭₎₎̊₊♡ (⋈◍>◡<◍) ʕ•̫͡• ʔ•̫͡•ཻʕ•̫͡•ʔ•͓͡•ʔ.•♫•♬ •♬•♫•.✿.。.:* ☆ .:**:.☆*.:。.✿ *★°*:.☆:*.°★*
●▂● ●0● ●︿● ●ω● ●﹏● ●△● ●▽● ♡⃝ ʜᴇʟʟᴏ •ᴗ• ☽⋆
∩ ∩ ̋(๑˃́ꇴ˂̀๑) ᐕ)⁾⁾ *:ஐ (๑´ᵕ`) ஐ:* *ଘ(੭*ˊᵕˋ)੭* (੭ˊᵕˋ)੭* ੈ✩˚
>(>_<)<
I I
I I ʕง•ᴥ•ʔง
IU UI
I I ꉂꉂ꒰•̤▿•̤*ૢ꒱
≧▂≦ ≧0≦ ≧︿≦ ≧ω≦ ≧﹏≦ ≧△≦ ꒰๑˃͈꒵˂͈๑꒱
☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫
(~o▔▽▔)~o o~(▔▽▔o~) ‿︵‿︵‿︵୨˚̣̣̣͙୧ - - - -୨˚̣̣̣͙୧‿︵‿︵‿︵
*/
#include<bits/stdc++.h>
using namespace std;
#define lll __int128
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> PII;
const int mod=1e9+7;
inline ll read()
{
ll x = 0, y = 1;
char c = getchar();
while (!isdigit(c))
{
if (c == '-')
y = -1;
c = getchar();
}
while (isdigit(c))
{
x = (x << 3) + (x << 1) + (c ^ 48);
c = getchar();
}
return x *= y;
}
inline void write(ll x)
{
if (x < 0)
x = -x, putchar('-');
ll sta[35], top = 0;
do
sta[top++] = x % 10, x /= 10;
while (x);
while (top)
putchar(sta[--top] + '0');
}
const int N = 3e5 + 10;
int a[N];
void Miraitowa(){
int n;
cin >> n;
for (int i = 1; i <= n;i++){
string s;
cin >> s;
if(s[s.size()-1]=='t') a[i] = 1;
else a[i] = 0;
}
for (int i = 1; i < n;i++){
if(a[i]==a[i+1]&&a[i]==1){
if(i+1==n){
cout << "Yes" << endl;
return;
}
else{
cout << "No" << endl;
return;
}
}
}
cout << "Yes" << endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
// int t;
// cin>>t;
// while(t--)
Miraitowa();
return 0;
};
B. Grid Walk
/* ʕ•̀ ω • ʔ *˘︶˘*).。.:*♡ (∗ᵒ̶̶̷̀ω˂̶́∗)੭₎₎̊₊♡ (⋈◍>◡<◍) ʕ•̫͡• ʔ•̫͡•ཻʕ•̫͡•ʔ•͓͡•ʔ.•♫•♬ •♬•♫•.✿.。.:* ☆ .:**:.☆*.:。.✿ *★°*:.☆:*.°★*
●▂● ●0● ●︿● ●ω● ●﹏● ●△● ●▽● ♡⃝ ʜᴇʟʟᴏ •ᴗ• ☽⋆
∩ ∩ ̋(๑˃́ꇴ˂̀๑) ᐕ)⁾⁾ *:ஐ (๑´ᵕ`) ஐ:* *ଘ(੭*ˊᵕˋ)੭* (੭ˊᵕˋ)੭* ੈ✩˚
>(>_<)<
I I
I I ʕง•ᴥ•ʔง
IU UI
I I ꉂꉂ꒰•̤▿•̤*ૢ꒱
≧▂≦ ≧0≦ ≧︿≦ ≧ω≦ ≧﹏≦ ≧△≦ ꒰๑˃͈꒵˂͈๑꒱
☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫
(~o▔▽▔)~o o~(▔▽▔o~) ‿︵‿︵‿︵୨˚̣̣̣͙୧ - - - -୨˚̣̣̣͙୧‿︵‿︵‿︵
*/
#include<bits/stdc++.h>
using namespace std;
#define lll __int128
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> PII;
const int mod=1e9+7;
inline ll read()
{
ll x = 0, y = 1;
char c = getchar();
while (!isdigit(c))
{
if (c == '-')
y = -1;
c = getchar();
}
while (isdigit(c))
{
x = (x << 3) + (x << 1) + (c ^ 48);
c = getchar();
}
return x *= y;
}
inline void write(ll x)
{
if (x < 0)
x = -x, putchar('-');
ll sta[35], top = 0;
do
sta[top++] = x % 10, x /= 10;
while (x);
while (top)
putchar(sta[--top] + '0');
}
int n, m;
char a[1000][1000];
void Miraitowa(){
cin >> n >> m;
int sx, sy;
cin >> sx >> sy;
for (int i = 1; i <= n;i++)
for (int j = 1; j <= m;j++)
cin >> a[i][j];
string s;
cin >> s;
for (int i = 0; i < s.size();i++){
if(s[i]=='U'&&a[sx-1][sy]=='.')
sx--;
if (s[i] == 'L' && a[sx][sy-1] == '.')
sy--;
if (s[i] == 'R' && a[sx][sy+1] == '.')
sy++;
if (s[i] == 'D' && a[sx+1][sy] == '.')
sx++;
}
cout << sx << " " << sy << endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
// int t;
// cin>>t;
// while(t--)
Miraitowa();
return 0;
};
C.Minimum Glutton
/* ʕ•̀ ω • ʔ *˘︶˘*).。.:*♡ (∗ᵒ̶̶̷̀ω˂̶́∗)੭₎₎̊₊♡ (⋈◍>◡<◍) ʕ•̫͡• ʔ•̫͡•ཻʕ•̫͡•ʔ•͓͡•ʔ.•♫•♬ •♬•♫•.✿.。.:* ☆ .:**:.☆*.:。.✿ *★°*:.☆:*.°★*
●▂● ●0● ●︿● ●ω● ●﹏● ●△● ●▽● ♡⃝ ʜᴇʟʟᴏ •ᴗ• ☽⋆
∩ ∩ ̋(๑˃́ꇴ˂̀๑) ᐕ)⁾⁾ *:ஐ (๑´ᵕ`) ஐ:* *ଘ(੭*ˊᵕˋ)੭* (੭ˊᵕˋ)੭* ੈ✩˚
>(>_<)<
I I
I I ʕง•ᴥ•ʔง
IU UI
I I ꉂꉂ꒰•̤▿•̤*ૢ꒱
≧▂≦ ≧0≦ ≧︿≦ ≧ω≦ ≧﹏≦ ≧△≦ ꒰๑˃͈꒵˂͈๑꒱
☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫
(~o▔▽▔)~o o~(▔▽▔o~) ‿︵‿︵‿︵୨˚̣̣̣͙୧ - - - -୨˚̣̣̣͙୧‿︵‿︵‿︵
*/
#include<bits/stdc++.h>
using namespace std;
#define lll __int128
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> PII;
const int mod=1e9+7;
inline ll read()
{
ll x = 0, y = 1;
char c = getchar();
while (!isdigit(c))
{
if (c == '-')
y = -1;
c = getchar();
}
while (isdigit(c))
{
x = (x << 3) + (x << 1) + (c ^ 48);
c = getchar();
}
return x *= y;
}
inline void write(ll x)
{
if (x < 0)
x = -x, putchar('-');
ll sta[35], top = 0;
do
sta[top++] = x % 10, x /= 10;
while (x);
while (top)
putchar(sta[--top] + '0');
}
const int N = 2e5 + 10;
PII a[N];
bool cmp1(PII a,PII b){
return a.first > b.first;
}
bool cmp2(PII a,PII b){
return a.second > b.second;
}
void Miraitowa(){
ll n, x, y;
cin >> n >> x >> y;
for (int i = 1; i <= n;i++)
cin >> a[i].first ;
for (int i = 1; i <= n;i++)
cin >> a[i].second;
sort(a + 1, a + 1 + n, cmp1);
ll w1 = 0, w2 = 0, cnt = 0;
for (int i = 1; i <= n; i++){
w1 += a[i].first, w2 += a[i].second;
if(w1>x||w2>y){
cnt = i;
break;
}
cnt++;
}
ll ans = cnt;
// for (int i = 1; i <= n;i++)
// cout << a[i].first << " " << a[i].second << endl;
w1 = 0, w2 = 0, cnt = 0;
sort(a + 1, a + 1 + n, cmp2);
for (int i = 1; i <= n; i++)
{
w1 += a[i].first, w2 += a[i].second;
if (w1 > x || w2 > y)
{
cnt = i ;
break;
}
cnt++;
}
cout << min(ans, cnt) << endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
// int t;
// cin>>t;
// while(t--)
Miraitowa();
return 0;
};
D.Minimum Glutton
/* ʕ•̀ ω • ʔ *˘︶˘*).。.:*♡ (∗ᵒ̶̶̷̀ω˂̶́∗)੭₎₎̊₊♡ (⋈◍>◡<◍) ʕ•̫͡• ʔ•̫͡•ཻʕ•̫͡•ʔ•͓͡•ʔ.•♫•♬ •♬•♫•.✿.。.:* ☆ .:**:.☆*.:。.✿ *★°*:.☆:*.°★*
●▂● ●0● ●︿● ●ω● ●﹏● ●△● ●▽● ♡⃝ ʜᴇʟʟᴏ •ᴗ• ☽⋆
∩ ∩ ̋(๑˃́ꇴ˂̀๑) ᐕ)⁾⁾ *:ஐ (๑´ᵕ`) ஐ:* *ଘ(੭*ˊᵕˋ)੭* (੭ˊᵕˋ)੭* ੈ✩˚
>(>_<)<
I I
I I ʕง•ᴥ•ʔง
IU UI
I I ꉂꉂ꒰•̤▿•̤*ૢ꒱
≧▂≦ ≧0≦ ≧︿≦ ≧ω≦ ≧﹏≦ ≧△≦ ꒰๑˃͈꒵˂͈๑꒱
☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫
(~o▔▽▔)~o o~(▔▽▔o~) ‿︵‿︵‿︵୨˚̣̣̣͙୧ - - - -୨˚̣̣̣͙୧‿︵‿︵‿︵
*/
#include<bits/stdc++.h>
using namespace std;
#define lll __int128
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> PII;
const int mod=1e9+7;
inline ll read()
{
ll x = 0, y = 1;
char c = getchar();
while (!isdigit(c))
{
if (c == '-')
y = -1;
c = getchar();
}
while (isdigit(c))
{
x = (x << 3) + (x << 1) + (c ^ 48);
c = getchar();
}
return x *= y;
}
inline void write(ll x)
{
if (x < 0)
x = -x, putchar('-');
ll sta[35], top = 0;
do
sta[top++] = x % 10, x /= 10;
while (x);
while (top)
putchar(sta[--top] + '0');
}
const int N = 4e5 + 10;
ll n, q;
ll a[N];
ll getl(ll d, ll x)
{
ll lo = lower_bound(a + 1, a + 1 + n, x - d) - a, ro = upper_bound(a + 1, a + 1 + n, x + d) - a - 1;
return ro - lo + 1;
}
void Miraitowa(){
cin >> n >> q;
for (int i = 1; i <= n;i++) cin >> a[i];
sort(a + 1, a + 1 + n);
while(q--){
ll x, k;
cin >> x >> k;
ll l = 0, r = 3e8, res = 0;
while(l<=r){
int mid = l + r >> 1;
if(getl(mid,x)>=k) r = mid - 1, res = mid;
else l = mid + 1;
}
cout << res << endl;
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
// int t;
// cin>>t;
// while(t--)
Miraitowa();
return 0;
};
E. Maximum Glutton
/* ʕ•̀ ω • ʔ *˘︶˘*).。.:*♡ (∗ᵒ̶̶̷̀ω˂̶́∗)੭₎₎̊₊♡ (⋈◍>◡<◍) ʕ•̫͡• ʔ•̫͡•ཻʕ•̫͡•ʔ•͓͡•ʔ.•♫•♬ •♬•♫•.✿.。.:* ☆ .:**:.☆*.:。.✿ *★°*:.☆:*.°★*
●▂● ●0● ●︿● ●ω● ●﹏● ●△● ●▽● ♡⃝ ʜᴇʟʟᴏ •ᴗ• ☽⋆
∩ ∩ ̋(๑˃́ꇴ˂̀๑) ᐕ)⁾⁾ *:ஐ (๑´ᵕ`) ஐ:* *ଘ(੭*ˊᵕˋ)੭* (੭ˊᵕˋ)੭* ੈ✩˚
>(>_<)<
I I
I I ʕง•ᴥ•ʔง
IU UI
I I ꉂꉂ꒰•̤▿•̤*ૢ꒱
≧▂≦ ≧0≦ ≧︿≦ ≧ω≦ ≧﹏≦ ≧△≦ ꒰๑˃͈꒵˂͈๑꒱
☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫
(~o▔▽▔)~o o~(▔▽▔o~) ‿︵‿︵‿︵୨˚̣̣̣͙୧ - - - -୨˚̣̣̣͙୧‿︵‿︵‿︵
*/
#include <bits/stdc++.h>
using namespace std;
#define lll __int128
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> PII;
const int mod = 1e9 + 7;
inline ll read()
{
ll x = 0, y = 1;
char c = getchar();
while (!isdigit(c))
{
if (c == '-')
y = -1;
c = getchar();
}
while (isdigit(c))
{
x = (x << 3) + (x << 1) + (c ^ 48);
c = getchar();
}
return x *= y;
}
inline void write(ll x)
{
if (x < 0)
x = -x, putchar('-');
ll sta[35], top = 0;
do
sta[top++] = x % 10, x /= 10;
while (x);
while (top)
putchar(sta[--top] + '0');
}
const int N = 100, M = 2e4 + 10;
int f[N][M][N];
int n, X, Y;
void Miraitowa()
{
cin >> n >> X >> Y;
memset(f, 0x3f, sizeof f);
f[0][0][0] = 0;
for (int i = 1; i <= n;i++){
int a, b;
cin >> a >> b;
for (int k = 0; k <= X; k++)
for (int j = 0; j <= i; j++)
{
f[i][k][j] = f[i - 1][k][j];
if (j && k >= a)
f[i][k][j] = min(f[i][k][j], f[i - 1][k-a][j-1] + b);
}
}
int res = 0;
for (int j = 0; j <= X; j++)
for (int i = 0; i <= n; i++)
if(f[n][j][i]<=Y)
res = max(res, min(i + 1, n));
cout << res << endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
// int t;
// cin >> t;
// while (t--)
Miraitowa();
return 0;
};