题解 | 田忌赛马

田忌赛马

https://www.nowcoder.com/practice/49d799f65a0749588e9cd7e6135a4a9a

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main() {
    int v1, v2, v3;
    int a1, a2, a3;
    cin >> v1 >> v2 >> v3;
    cin >> a1 >> a2 >> a3;
    vector<int> qww = {v1, v2, v3};
    vector<int> tj = {a1, a2, a3};
    sort(tj.begin(), tj.end());
    int result = 0;
    for (int horse : qww) {
        for (int i = 0; i < tj.size(); i++) {
            if (tj[i] > horse) {
                result++;
                tj.erase(tj.begin() + i);
                break;
            }
        }
    }
    string r = result >= 2 ? "Yes" : "No";
    cout << r << endl;
    return 0;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务