为什么我的通过不了所有的案例呢,只有70% ?

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

struct Movie{
    long long bj;
    long long cj;
    int32_t scoreb;
    int32_t scorec;
};
typedef pair<int, Movie> PAIR;
struct CmpByValue {
  bool operator()(PAIR& k1, PAIR& k2) {
    if(k2.second.scoreb >= k1.second.scoreb){
        if(k2.second.scoreb > k1.second.scoreb){
            return false;
        }else if(k2.second.scorec >= k1.second.scorec){
            return false;
        }else{
            return true;
        }
    }else{
        return true;
    }
  }
};

int32_t caculateNum(long long a,long long b[]){
    int32_t num = 0;
    int32_t n = sizeof(b);
    for(int i=0;i<n;i++){
        if(b[i] == a){
            num++;
        }
    }
    return num;
};
int main()
{
    int32_t n,m;
    cin >> n;
    long long a[n];
    for(int i = 0; i < n;i++){
        cin >> a[i];
    }
    cin >> m;
    map<int,Movie> strMap;
    for(int i = 1; i <= m;i++){
        Movie temp;
        temp.cj = 0;
        temp.bj = 0;
        temp.scoreb = 0;
        temp.scorec = 0;
        cin >> temp.bj;
        pair<int,Movie> value(i,temp);
        strMap.insert(value);
    }
    for(int i = 1; i <= m;i++){
        map<int,Movie>::iterator iter1;
        iter1 = strMap.find(i);
        if(iter1 != strMap.end()){
            cin >>iter1->second.cj;
        }
    }
    map<int,Movie>::iterator iter1 = strMap.begin();
    while(iter1 != strMap.end()){
        iter1->second.scoreb = caculateNum(iter1->second.bj,a);
        iter1->second.scorec = caculateNum(iter1->second.cj,a);
        iter1++;
    }
    vector<PAIR> name_score_vec(strMap.begin(), strMap.end());
    sort(name_score_vec.begin(), name_score_vec.end(), CmpByValue());

    cout<<name_score_vec[0].first<<endl;
    return 0;
}

全部评论
不要用cin cout这样的呢
点赞 回复 分享
发布于 2019-10-15 20:05

相关推荐

小浪_Coding:找硬件测试,也可兼顾软测欧, 简历还可以的 ,注意排版,项目写的有条理一点, 然后个人技能多加点, 润色好简历之后就开始沟通海投了,深圳,东莞这边做硬件相关的公司还不少, 医疗类,仪器类的都可以尝试
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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