2020 CCPC-Wannafly Winter Camp Day6 C

2020 CCPC-Wannafly Winter Camp Day6 C

文章目录

题目

2020 CCPC-Wannafly Winter Camp Day6 C

思路

其实挺简单,就是说如果你想杀敌多,那么肯定是让没有杀敌能力的无毒随从去破盾,就是让无毒的优先攻击有盾的,然后让有毒的乱杀(注意有嘲讽就优先攻击嘲讽,规定好的),不想杀敌就反过来,让有毒的破盾,然后稍微总结了一下攻击优先度,模拟就行,代码打得很模拟,没有往简单的方向打
2020 CCPC-Wannafly Winter Camp Day6 C

代码

#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
using namespace std;
#define dbg(x) cerr << #x " = " << x <<endl;
typedef pair<int, int> P;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while(t--)
    {
        int n, common, shield, yell, shyell;
        cin >> n >> common >> shield >> yell >> shyell;
        int com = common, sh = shield, ye = yell, shy = shyell;
        string op, tmp;
        cin >> op;
        tmp = op;
        int max_ans = 0;
        int min_ans = 0;
        int len = tmp.size();
        for(int i = 0; i < len; i++)
        {
            if(tmp[i] == '1')
            {
                if(yell)
                {
                    yell--;
                    max_ans++;
                }
                else if(shyell)
                {
                    shyell--;
                    yell++;
                }
                else if(common)
                {
                    common--;
                    max_ans++;
                }
                else if(shield)
                {
                    shield--;
                    common++;
                }
            }
            else
            {
                if(shyell)
                {
                    shyell--;
                    yell++;
                }
                else if(yell)
                {
                    continue;
                }
                else if(shield)
                {
                    shield--;
                    common++;
                }
                else if(common)
                {
                    continue;
                }
            }
            

            if(op[i] == '1')
            {
                if(shy)
                {
                    shy--;
                    ye++;
                }
                else if(ye)
                {
                    ye--;
                    min_ans++;
                }
                else if(sh)
                {
                    sh--;
                    com++;
                }
                else if(com)
                {
                    com--;
                    min_ans++;
                }
            }
            else
            {
                if(ye)
                {
                    continue;
                }
                else if(shy)
                {
                    shy--;
                    ye++;
                }
                else if(com)
                {
                    continue;
                }
                else if(sh)
                {
                    sh--;
                    com++;
                }
            }
            
        }
        cout << max_ans << ' ' << min_ans << endl;
    }
}
2020 CCPC-Wannafly Winter Camp Day6 C2020 CCPC-Wannafly Winter Camp Day6 C CalculuUus 发布了6 篇原创文章 · 获赞 2 · 访问量 535 私信 关注
上一篇:mybatis一(常用配置信息和获取插入后id)


下一篇:玩转Vim 编辑器