Hello 2023

Hello 2023

没什么压力的时候VP CF还是蛮开心的。
传送门

A. Hall of Fame

L灯照亮左边,R照亮右边。

#include<bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T;
    cin >> T;
    while (T--) {
        int n;
        cin >> n;
        string s;
        cin >> s;
        if(s.find("RL")!=string::npos){
            cout<<0<<endl;
            continue;
        }
        else if(s.find("LR")!=string::npos){
            cout<<s.find("LR")+1<<endl;
           continue;
        }
       else cout<<-1<<endl;
}
}

MKnez’s ConstructiveForces Task

推个柿子就好。
数组和=相邻两数和,构造。
在这里插入图片描述
字母没换搞得WA了一次。

#include<bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T;
    cin >> T;
    while (T--) {
     int n;
     cin>>n;
     if(n%2==0){
         cout<<"Yes"<<endl;
         for(int i=0;i<n;i++){
             if(i==n-1){
                 if(i%2) cout<<-1;
                 else cout<<1;
                 break;
             }
             if(i%2) cout<<-1<<" ";
             else cout<<1<<" ";
         }
         cout<<endl;
     }
     else{
         if(n<=3) cout<<"No"<<endl;
         else{
             cout<<"Yes"<<endl;
             int k = n / 2;
             for(int i = 1;i <= n;i++){
                 if(i==n){
                    cout<<k-1;
                    break;
                 }
                 if(i%2==1) cout<<k-1<<" ";
                 else cout<<-k<<" ";
             }
         }
         cout<<endl;
     }
    }
}

C. Least Prefix Sum

给n,m,数量为n的数组。
要求前m个的前缀和为数组最小的前缀和(之一)。
在这里插入图片描述

#include<bits/stdc++.h>

typedef long long ll;
using namespace std;
vector<ll> a;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T;
    cin >> T;
    while (T--) {
        int cnt = 0;
        a.clear();
        int n, m;
        cin >> n>>m;
        for (int i = 0; i < n; i++) {
            int tmp;
            cin >> tmp;
            a.push_back(tmp);
        }
        ll presum = 0ll;
        priority_queue<int,vector<int>,less<int>>pre;
        priority_queue<int,vector<int>,greater<int>>aft;
        for (int i = m - 1; i > 0; i--) {
            presum += a[i];
            pre.push(a[i]);
            if(presum>0){
                presum -= 2 * pre.top();
                pre.pop();
                cnt++;
            }
        }
        ll aftsum = 0ll;
        for(int i = m;i<n;i++){
            aft.push(a[i]);
            aftsum += a[i];
            if (aftsum < 0)
            {
                aftsum -= 2 * aft.top();
                aft.pop();
                cnt++;
            }
        }
        cout<<cnt<<endl;
    }
}

D. Boris and His Amazing Haircut

VP的时候有人找玩鹅鹅鸭去了,但是没加速器也玩不了,但也不想打题了。
只能说现在不定目标打题目心情是好了,但也比较懒了。
刚补的,STL忘差不多呃,RE好久。
逻辑主要是单调栈,看最后一个for循环部分的逻辑很容易明白。

#include<bits/stdc++.h>

using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    int f = 1;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        if (b[i] > a[i]) {
            f = 0;
        }
    }
    int m;
    cin >> m;
    map<int, int> mp;
    int tmpp;
    for (int i = 0; i < m; i++) {
        cin >> tmpp;
        mp[tmpp]++;
    }

    if (f == 0) {
        cout << "No" << endl;
        return;
    }
    stack<int> s;
    for (int i = 0; i < n; i++) {
        while (!s.empty()&&b[i] > s.top()) {
            s.pop();
        }
        if (a[i] > b[i]) {
            if (s.empty() || b[i] != s.top()) {
                if (mp[b[i]] > 0) {
                    mp[b[i]]--;
                    s.push(b[i]);
                } else {
                    f = 0;
                }
            }
        }
    }
    if (f == 0) {
        cout << "No" << endl;
    } else cout << "yes" << endl;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T;
    cin >> T;
    while (T--) {
        solve();
    }
}

E. Anya’s Simultaneous Exhibition

可能补,大概率不补。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值