### A. Extreme Subtraction

#### 题意：

4 5 6 4 5 6 4 8 9

4 5 6 4 5 6 4 4 4

4 5 6 4 4 4 2 2 2

4 4 4 2 2 2 0 0 0

4 5 6 4 5 6 4 8 9

2 3 4 4 5 6 4 8 9

0 1 2 2 3 4 4 8 9

#### AC代码：

1：

int n;        cin >> n;        vector<int> a(n);        for (int &i : a)            cin >> i;        int num1 = 0, num2 = 0;        for (int i = 0; i < n-1; ++i)        {            if (a[i] <= a[i + 1])                num2 += a[i + 1] - a[i];            else                num1 += a[i] - a[i + 1];        }        if (num1 <= a[0] || num2 <= a[n - 1])            puts("YES");        else            puts("NO");

2：

int n;        cin >> n;        vector<int> a(n);        for (int &i : a)            cin >> i;        int num = 0;        for (int i = 0; i < n - 1; ++i)            num += abs(a[i + 1] - a[i]);        if (num <= a[0] + a[n - 1])            puts("YES");        else            puts("NO");

### B. Identify the Operations

#### AC代码：

const int N = 2e5 + 50;const ll mod = 998244353;int a[N], b[N], pos[N], vis[N];int n, k;int main(){    int t;    sd(t);    while (t--)    {        sdd(n, k);        rep(i, 1, n)        {            pos[i] = 0;            vis[i] = 0;        }        rep(i, 1, n)        {            sd(a[i]);            pos[a[i]] = i;        }        vis[0] = vis[n + 1] = n + 7;        rep(i, 1, k)        {            sd(b[i]);            vis[pos[b[i]]] = i;        }        ll ans = 1;        rep(i, 1, k)        {            int id = pos[b[i]];            int now = 0;            if (vis[id + 1] <= vis[id])                now++;            if (vis[id - 1] <= vis[id])                now++;            ans = ans * now % mod;        }        pld(ans);    }    return 0;}