• 《Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020


    A:水题:

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long LL;
    typedef pair<LL,int> pii;
    const int N = 2e5+5;
    const int M = 1e6+5;
    const LL Mod = 998244353;
    #define pi acos(-1)
    #define INF 1e18
    #define CT0 cin.tie(0),cout.tie(0)
    #define IO ios::sync_with_stdio(false)
    #define dbg(ax) cout << "now this num is " << ax << endl;
    namespace FASTIO{
        inline LL read(){
            LL x = 0,f = 1;char c = getchar();
            while(c < '0' || c > '9'){if(c == '-') f = -1;c = getchar();}
            while(c >= '0' && c <= '9'){x = (x<<1)+(x<<3)+(c^48);c = getchar();}
            return x*f;
        }
    }
    using namespace FASTIO;
    
    int main()
    {
        int ca;ca = read();
        while(ca--)
        {
            int n;n = read();
            for(int i = 4 * n,j = 1;j <= n;i -= 2,++j) printf("%d%c",i,j == n ? '
    ' : ' ');
        }
        return 0;
    }
    View Code

    B:贪心即可

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long LL;
    typedef pair<LL,int> pii;
    const int N = 1e5+5;
    const int M = 1e6+5;
    const LL Mod = 998244353;
    #define pi acos(-1)
    #define INF 1e18
    #define CT0 cin.tie(0),cout.tie(0)
    #define IO ios::sync_with_stdio(false)
    #define dbg(ax) cout << "now this num is " << ax << endl;
    namespace FASTIO{
        inline LL read(){
            LL x = 0,f = 1;char c = getchar();
            while(c < '0' || c > '9'){if(c == '-') f = -1;c = getchar();}
            while(c >= '0' && c <= '9'){x = (x<<1)+(x<<3)+(c^48);c = getchar();}
            return x*f;
        }
    }
    using namespace FASTIO;
    
    int main()
    {
        int ca;ca = read();
        while(ca--)
        {
            int a,b;a = read(),b = read();
            string s;cin >> s;
            int n = s.size();
            int f = 0,ans = 0,ma = 0;
            for(int i = 0;i < n;++i){
                if(s[i] == '1')
                {
                    if(f == 0)
                    {
                        if(ans != 0 && b * ma < a) ans += b * ma;
                        else ans += a;
                    }
                    ma = 0,f = 1;
                }
                else ma++,f = 0;
            }
            printf("%d
    ",ans);
        }
        return 0;
    }
    View Code

    C:堆维护

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long LL;
    typedef pair<LL,int> pii;
    const int N = 2e5+5;
    const int M = 1e6+5;
    const LL Mod = 998244353;
    #define pi acos(-1)
    #define INF 1e18
    #define CT0 cin.tie(0),cout.tie(0)
    #define IO ios::sync_with_stdio(false)
    #define dbg(ax) cout << "now this num is " << ax << endl;
    namespace FASTIO{
        inline LL read(){
            LL x = 0,f = 1;char c = getchar();
            while(c < '0' || c > '9'){if(c == '-') f = -1;c = getchar();}
            while(c >= '0' && c <= '9'){x = (x<<1)+(x<<3)+(c^48);c = getchar();}
            return x*f;
        }
    }
    using namespace FASTIO;
    
    struct Node{
        LL x;int id;
        bool operator < (const Node a)const{
        return x < a.x;
        }
    };
    LL b[N];
    int main()
    {
        int ca;ca = read();
        while(ca--)
        {
            int n;n = read();
            priority_queue<Node> Q;
            LL sum = 0;
            for(int i = 1;i <= n;++i){
                int x;x = read();
                Q.push(Node{x,i});
            }
            for(int i = 1;i <= n;++i) b[i] = read();
            while(!Q.empty()){
                Node a = Q.top();
                if(sum + b[a.id] <= a.x) sum += b[a.id],Q.pop();
                else break;
            }
            LL ans = 0;
            if(!Q.empty()) ans = Q.top().x;
            ans = max(ans,sum);
            printf("%lld
    ",ans);
        }
        return 0;
    }
    View Code

    D:没想到这个看起来简单的题能卡我这么久。

    主要的思路就是从左边开始删,然后不够的代价从右边补,然后看中间是否某个值 < 0。

    亿点细节:一开始是used取最大值,仔细思考之后used应该是叠加的,因为我们每次都让a[i] - used.。

    然后我们每次减去之后显然前面的都是前面的区间里的最小值了,所以我们比较的时候应该去比较和最小值的差距。

    主要是这里一开始比的都不是和最小值的差距。

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long LL;
    typedef pair<LL,int> pii;
    const int N = 2e5+5;
    const int M = 1e6+5;
    const LL Mod = 998244353;
    #define pi acos(-1)
    #define INF 1e18
    #define CT0 cin.tie(0),cout.tie(0)
    #define IO ios::sync_with_stdio(false)
    #define dbg(ax) cout << "now this num is " << ax << endl;
    namespace FASTIO{
        inline LL read(){
            LL x = 0,f = 1;char c = getchar();
            while(c < '0' || c > '9'){if(c == '-') f = -1;c = getchar();}
            while(c >= '0' && c <= '9'){x = (x<<1)+(x<<3)+(c^48);c = getchar();}
            return x*f;
        }
    }
    using namespace FASTIO;
    
    int a[N];
    int main()
    {
        int ca;ca = read();
        while(ca--)
        {
            int n;n = read();
            for(int i = 1;i <= n;++i) a[i] = read();
            int f = 0,used = 0,pre = a[1];
            for(int i = 1;i <= n;++i){
                a[i] -= used;
                if(a[i] < 0){f = 1;break;}
                if(a[i] > pre) used += a[i] - pre;
                pre = min(pre,a[i]);
            }
            printf("%s
    ",f ? "NO" : "YES");
        }
        system("pause");
        return 0;
    }
    View Code

     E:待补

    F:题意是问使答案等于B序列的方案数,一开始没读对。

    思路:因为是有顺序的,对于i位置,显然可以删去左边的和删去右边的来得到,这样就有两种可能即方案数 * 2。

    然后如果两边只有一边可以删,那就方案数 * 1。

    如果两边都要不能删,那就说明不存在满足的方案。

    对于能删的情况,我们在遍历中更新即可。

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long LL;
    typedef pair<int,int> pii;
    const int N = 2e5+5;
    const int M = 1e6+5;
    const LL Mod = 998244353;
    #define pi acos(-1)
    #define INF 1e18
    #define CT0 cin.tie(0),cout.tie(0)
    #define IO ios::sync_with_stdio(false)
    #define dbg(ax) cout << "now this num is " << ax << endl;
    namespace FASTIO{
        inline int read()
        {
            int x = 0,f = 1;char c = getchar();
            while(c < '0' || c > '9'){if(c == '-')f = -1;c = getchar();}
            while(c >= '0' && c <= '9'){x = (x << 1) + (x << 3) + (c ^ 48);c = getchar();}
            return x * f;
        }
    }
    using namespace FASTIO;
    
    int a[N],b[N],pos[N];
    bool vis[N];
    int main()
    {
        int ca;ca = read();
        while(ca--)
        {
            memset(vis,0,sizeof(vis));
            int n,k;n = read(),k = read();
            for(int i = 1;i <= n;++i) a[i] = read(),pos[a[i]] = i;
            for(int i = 1;i <= k;++i) b[i] = read(),vis[pos[b[i]]] = 1;
            vis[0] = 1,vis[n + 1] = 1;
            LL ans = 1;
            for(int i = 1;i <= k;++i)
            {
                int ma = pos[b[i]];
                if(vis[ma - 1] == 0 && vis[ma + 1] == 0) ans = ans * 2 % Mod; 
                else if(vis[ma - 1] == 0 || vis[ma + 1] == 0) ans = ans * 1;
                else{ans = 0;break;}
                vis[ma] = 0;
            }
            printf("%lld
    ",ans);
        }
        system("pause");
        return 0;
    }
    View Code
  • 相关阅读:
    JMeter的JavaRequest探究
    记一次生产压测遇到的"坑"
    JMeter之If Controller深究二
    JMeter之SteppingShape
    那些年拿过的shell之adminer
    Spring Boot Actuator H2 RCE复现
    使用sqlmap结合dnslog快速注入
    一次稍显曲折的爆破经历
    无回显、不出网命令执行测试方式
    实战绕过某waf后缀检测内容检测
  • 原文地址:https://www.cnblogs.com/zwjzwj/p/13972490.html
Copyright © 2020-2023  润新知