9.15 爱奇艺笔试编程题

局长的食物

#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <bitset>
// #include <unistd.h>
#include <unordered_map>

using namespace std;

#define LL long long
#define pb push_back
#define mk make_pair
#define pill pair<int, int>
#define fi first
#define se second
#define mst(a, b) memset(a, b, sizeof a)
#define lson (rt << 1)
#define rson ((rt << 1) | 1)

const int qq = 1e5 + 10;
const int INF = 1e9 + 10;
const int MOD = 1e9 + 7;
struct Food {
    int x;
    int id;
    bool operator < (const Food &d) const {
        return x > d.x;
    }
}food[qq];
int n, m, p;
int tmp[qq];

int main() {
    #ifdef ONLINE_JUDGE
    #else
        freopen("in.txt", "r", stdin);
    #endif
    scanf("%d%d%d", &n, &m, &p);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &food[i].x);
        food[i].id = i;
    }
    string st;
    while (m--) {
        getline(cin, st);
        int num = 0, len = st.size();
        for (int i = 2; i < len; ++i) {
            num = num * 10 + st[i] - '0';
        }
        if (st[0] == 'B')
            food[num].x--;
        else
            food[num].x++;
    }
    int ans = 0, id = 0;
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
        if (food[i].x > food[p].x) {
            cnt++;
        }
    }
    printf("%d\n", cnt + 1);
    return 0;
}
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <bitset>
// #include <unistd.h>
#include <unordered_map>

using namespace std;

#define LL long long
#define pb push_back
#define mk make_pair
#define pill pair<int, int>
#define fi first
#define se second
#define mst(a, b) memset(a, b, sizeof a)
#define lson (rt << 1)
#define rson ((rt << 1) | 1)

const int qq = 1e5 + 10;
const int INF = 1e9 + 10;
const int MOD = 1e9 + 7;
char st[qq];
int a[10], b[10];

int main() {
    #ifdef ONLINE_JUDGE
    #else
        freopen("in.txt", "r", stdin);
    #endif
    scanf("%s", st);
    int ans = INF;
    for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) {
            for (int k = 0; k < 10; ++k) {
                int a = i + j + k;
                for (int o = 0; o < 10; ++o) {
                    for (int p = 0; p < 10; ++p) {
                        for (int q = 0; q < 10; ++q) {
                            int b = o + p + q;
                            if (a == b) {
                                int tmp = 0;
                                if (i != st[0] - '0')   tmp++;
                                if (j != st[1] - '0')   tmp++;
                                if (k != st[2] - '0')   tmp++;
                                if (o != st[3] - '0')   tmp++;
                                if (p != st[4] - '0')   tmp++;
                                if (q != st[5] - '0')   tmp++;
                                ans = min(ans, tmp);
                            }
                        }
                    }
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值