# HDU 5289 Assignment

2022年11月24日
0 收藏 535 点赞 4,496 浏览 1557 个字

`#include<stdio.h>#include<iostream>#include<algorithm>#include<string>#include<string.h>#include<math.h>#include<limits.h>#include<time.h>#include<stdlib.h>#include<map>#include<queue>#include<set>#include<stack>#include<vector>#define LL long long#define lson l, m, rt << 1#define rson m + 1, r, rt << 1 | 1using namespace std;int MIN[100005 << 2], MAX[100005 << 2];int a[100005];void pushupMIN(int rt){    MIN[rt] = min(MIN[rt << 1], MIN[rt << 1 | 1]);}void pushupMAX(int rt){    MAX[rt] = max(MAX[rt << 1], MAX[rt << 1 | 1]);}void build(int l, int r, int rt){    if(l == r)    {        scanf("%d", &a[l]);        MIN[rt] = MAX[rt] = a[l];        return;    }    int m = (l + r) >> 1;    build(lson);    build(rson);    pushupMIN(rt);    pushupMAX(rt);}int getMIN(int ll, int rr, int l, int r, int rt){    if(ll <= l && rr >= r)        return MIN[rt];    int res = INT_MAX;    int m = (l + r) >> 1;    if(ll <= m) res = min(res, getMIN(ll, rr, lson));    if(rr > m) res = min(res, getMIN(ll, rr, rson));    return res;}int getMAX(int ll, int rr, int l, int r, int rt){    if(ll <= l && rr >= r)        return MAX[rt];    int res = 0;    int m = (l + r) >> 1;    if(ll <= m) res = max(res, getMAX(ll, rr, lson));    if(rr > m) res = max(res, getMAX(ll, rr, rson));    return res;}int main(){    int T;    while(~scanf("%d", &T))    {        int n, k;        while(T--)        {            scanf("%d%d", &n, &k);            build(1, n, 1);            int flag = 0;            int l = 1, r = 0;            LL ans = 0;            while(r <= n)            {                if(r == n || flag)                {                    l++;                    int tmp1 = getMIN(l, r, 1, n, 1);                    int tmp2 = getMAX(l, r, 1, n, 1);                    if(tmp2 - tmp1 < k)                    {                        ans += r - l + 1;                        flag = 0;                        if(r == n)                            break;                    }                }                else                {                    r++;                    int tmp1 = getMIN(l, r, 1, n, 1);                    int tmp2 = getMAX(l, r, 1, n, 1);                    if(tmp2 - tmp1 < k)                    {                        ans += r - l + 1;                        if(r == n)                            break;                    }                    else                        flag = 1;                }            }            printf("%lld\n", ans);        }    }    return 0;}`

python开发_常用的python模块及安装方法

Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接：http://www.codeforces.com/contest/660/problem/CDes…

zengkefu@server1:/usr/src\$ uname -aLinux server1 4.10.0-19-generic #21…

Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式，并且由于涉及到要把拍到的照片显…

Struts的使用