U486352 郭叡喆VS亓鸿锦
查看原帖
U486352 郭叡喆VS亓鸿锦
1464414
ZZQ110803114514楼主2024/10/5 15:05
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
    int x, qihongjinPower;
    std::cin >> x >> qihongjinPower;
    std::vector<int> guoFriendsPower(x);
    for (int i = 0; i < x; ++i) {
        std::cin >> guoFriendsPower[i];
    }
    std::vector<char> options;
    int totalPowerOfGuoFriends = 0;
    for (int power : guoFriendsPower) {
        totalPowerOfGuoFriends += power;
    }
    // 使用 A
    totalPowerOfGuoFriends -= 3 * x;
    if (qihongjinPower > totalPowerOfGuoFriends) {
        options.push_back('A');
    }
    // 使用 B
    qihongjinPower += 15;
    if (qihongjinPower > totalPowerOfGuoFriends) {
        options.push_back('B');
    }
    // 使用 C
    std::sort(guoFriendsPower.begin(), guoFriendsPower.end());
    if (x > 2) {
        totalPowerOfGuoFriends -= guoFriendsPower[0] + guoFriendsPower[1];
        if (qihongjinPower > totalPowerOfGuoFriends) {
            options.push_back('C');
        }
    }
    if (options.empty()) {
        std::cout << "-1" << std::endl;
    } else {
        for (char option : options) {
            std::cout << option;
        }
        std::cout << std::endl;
    }
    return 0;
}

20 why

2024/10/5 15:05
加载中...