Codeforces Round #723 (Div. 2)补题

在这里插入图片描述
水题,只需要将序列分成两部分即可,一部分是大的,一部分是小的。

#include <cstdio>
#include <iostream>
#include <algorithm>
int T,a[105];
int main(int argc,char *argv[]){
    scanf("%d",&T);
    while(T--){
        int n;
        scanf("%d",&n);
        for(int i = 1;i <= 2 * n;i++){
            scanf("%d",&a[i]);
        }
        std::sort(a + 1,a + 2 * n + 1);
        for(int i = 1;i <= n;i++){
            printf("%d %d ",a[i],a[i + n]);
        }
        puts("");
    }
    return 0;
}

在这里插入图片描述
对于任意x,如果可以由以上数构成那么都有 x = ( 11 ∗ k 1 + 111 ∗ k 2 ) x = (11 * k_1 + 111*k_2) x=(11k1+111k2)
x = ( 11 ∗ k 1 + ( 11 ∗ 10 + 1 ) ∗ k 2 ) x = (11 * k_1 + (11 * 10 + 1) * k_2) x=(11k1+(1110+1)k2) x = 11 ∗ ( 10 ∗ k 2 + k 1 ) + k 2 x = 11 * (10*k_2 + k_1) + k_2 x=11(10k2+k1)+k2 所以
x m o d    11 = k 2 x \mod 11 = k2 xmod11=k2 x m o d    11 ≤ ⌊ x / 11 / 10 ⌋ x \mod 11 \le \lfloor x /11/10 \rfloor xmod11x/11/10

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        long long n;
        cin >> n;
        if (n % 11 <= n / 11 / 10)
            cout << "YES\n";
        else
            cout << "NO\n";
    }
    return 0;
}

在这里插入图片描述
对于第i个药剂,如果我们喝了之后状态依旧能大于0,那么我们就喝,如果我们喝了之后小于0,那么我们可以在1 - i 里找一个比i小或相等的替换掉,使喝的瓶数不变,我们可以用堆实现这一操作。

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <climits>
#include <utility>
int n;
std::priority_queue<int,std::vector<int>,std::greater<int> >q;
int main(int argc,char *argv[]){
    scanf("%d",&n);
    long long sum = 0;
    while(n--){
        int x;
        scanf("%d",&x);
        q.push(x);
        sum += x;
        while(sum < 0){
            sum -= q.top();
            q.pop();
        }
    }
    printf("%d\n",q.size());
    return 0;
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值