题解 | 田忌赛马

田忌赛马

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

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

int main() {
    vector<int> tj(3, 0), qi(3, 0);
    for (int i = 0; i < 3; i++){
        cin >> qi[i];
    }
    for (int i = 0; i < 3; i++){
        cin >> tj[i];
    }
    // notice that exist two in tj should >= 2 
    vector<int> beat(3, 0);
    for (int i = 0; i < 3; i ++){
        for (int j = 0; j < 3; j ++){
            if (tj[i] > qi[j]){
                beat[i] ++; 
            }
        }
    }
    if ((beat[0] && beat[2] ) || (beat[0] && beat[1]) || (beat[1]  && beat[2])){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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