• 题意:有\(n\)扇门,你每次可以攻击某个门,使其hp减少\(x\)(\(\le 0\)后就不可修复了),之后警察会修复某个门,使其hp增加\(y\),问你最多可以破坏多少扇门?

  • 题解:首先如果\(x>y\),那么我肯定全部都能破坏,否则,统计\(hp\le x\)的门的个数,谁先碰门谁先赢,而我是先手,所以能破坏的门的个数就是\(\lceil \frac{cnt}{2} \rceil\).

  • 代码:

    int n,x,y;
    int a[N]; int main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    n=read();
    x=read();
    y=read();
    int cnt=0;
    for(int i=1;i<=n;++i){
    a[i]=read();
    if(a[i]<=x) cnt++;
    } if(x>y) printf("%d\n",n);
    else{
    if(cnt==0) puts("0");
    else printf("%d\n",(cnt-1)/2+1);
    } return 0;
    }

Codeforces Round #531 (Div. 3) C. Doors Breaking and Repairing (博弈)的更多相关文章

  1. Codeforces Round #531 (Div. 3) ABCDEF题解

    Codeforces Round #531 (Div. 3) 题目总链接:https://codeforces.com/contest/1102 A. Integer Sequence Dividin ...

  2. Codeforces Round #184 (Div. 2) E. Playing with String(博弈)

    题目大意 两个人轮流在一个字符串上删掉一个字符,没有字符可删的人输掉游戏 删字符的规则如下: 1. 每次从一个字符串中选取一个字符,它是一个长度至少为 3 的奇回文串的中心 2. 删掉该字符,同时,他 ...

  3. Codeforces Round #531 (Div. 3) F. Elongated Matrix(状压DP)

    F. Elongated Matrix 题目链接:https://codeforces.com/contest/1102/problem/F 题意: 给出一个n*m的矩阵,现在可以随意交换任意的两行, ...

  4. Codeforces Round #531 (Div. 3)

    A:瞎猜. #include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); i ...

  5. Codeforces Round #531 (Div. 3) E. Monotonic Renumeration (构造)

    题意:给出一个长度为\(n\)的序列\(a\),根据\(a\)构造一个序列\(b\),要求: ​ 1.\(b_{1}=0\) ​ 2.对于\(i,j(i\le i,j \le n)\),若\(a_{i ...

  6. Codeforces Round #531 (Div. 3) D. Balanced Ternary String (贪心)

    题意:给你一个长度为\(3*n\)的字符串,要求修改最少的次数,使得字符串中\(0,1,2\)的个数相同,并且在最少次数的情况下使字典序最小. 题解:贪心,\(0\)一定放在前面,\(1\)和\(2\ ...

  7. Codeforces Round #531 (Div. 3) B. Array K-Coloring (结构体排序)

    题意:给你\(n\)个数字,用\(k\)种颜色给他们涂色,要求每个数字都要涂,每种颜色都要用,相同的数字不能涂一样的颜色. 题解:用结构体读入每个数字和它的位置,然后用桶记录每个数字出现的次数,判断是 ...

  8. Codeforces Round #228 (Div. 1) C. Fox and Card Game 博弈

    C. Fox and Card Game 题目连接: http://codeforces.com/contest/388/problem/C Description Fox Ciel is playi ...

  9. Codeforces Round #573 (Div. 2) E. Tokitsukaze and Duel (博弈)

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

随机推荐

  1. 【七天搞定Python】day01.Python环境配置、pip、IDE、注释、变量,数据类型、标识符/关键字、输出、输入

    什么是Python? 动态解释型语言,1982年由荷兰人Guido von Rossum发明. 更多细节可以google,这里不做展开. Python解释器: CPython(官方版本C语言实现) I ...

  2. Docker-常用基建的安装与部署

    一:Docker安装 1:通过yum安装docker yum -y install gcc yum -y install gcc-c++ yum remove docker \ docker-clie ...

  3. Python Pandas操作Excel

    Python Pandas操作Excel 前情提要 ☟ 本章使用的 Python3.6 Pandas==0.25.3 项目中需要用到excel的文件字段太多 考虑到后续字段命名的变动以及中文/英文/日 ...

  4. Linux 三剑客之 grep 使用详解

    Linux 最重要的三个命令在业界被称为三剑客,它们是:awk.sed.grep.sed 已经在上篇中讲过,本文要讲的是 grep 命令. 我们在使用 Linux 系统中,grep 命令的使用尤为频繁 ...

  5. nginx.service: control process exited, code=exited status=1

    安装linux的宝塔面板,结果面板显示nginx和php已经运行了,但是机器系统上并没有运行.记录一次nginx报错,操作步骤看下代码: [root@localhost nginx]# systemc ...

  6. Spark SQL如何选择join策略

    前言 众所周知,Catalyst Optimizer是Spark SQL的核心,它主要负责将SQL语句转换成最终的物理执行计划,在一定程度上决定了SQL执行的性能. Catalyst在由Optimiz ...

  7. Building a high performance JSON parser

    Building a high performance JSON parser https://dave.cheney.net/high-performance-json.html

  8. git branch --set-upstream-to=

    test@uat:/usr/server/app_server# git config --local -lcore.repositoryformatversion=0core.filemode=tr ...

  9. DevOps运动的缘起 将DevOps想象为一种编程语言里面的一个接口,而SRE类实现了这个接口

     SRE vs DevOps:是敌是友? - DockOne.io http://www.dockone.io/article/5935   RE vs DevOps:是敌是友? [编者的话]网站可靠 ...

  10. 从epoll构建muduo-1 mini-muduo介绍

    https://blog.csdn.net/voidccc/article/details/8719752 ========== https://blog.csdn.net/liangzhao_jay ...