lower_bound怎么操作二维数组啊
  • 板块CF670C Cinema
  • 楼主congya
  • 当前回复6
  • 已保存回复6
  • 发布时间2023/10/15 22:39
  • 上次更新2023/11/2 13:31:27
查看原帖
lower_bound怎么操作二维数组啊
989962
congya楼主2023/10/15 22:39
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

int scientist[200010];
struct video{
    int first,last;
}c[200010];
int point[600010][2];

int main()
{
    int n;
    cin >> n;
    int p=0;
    for (int i = 1; i <= n; i ++ ){
        scanf("%d", &scientist[i]);
        point[p++][0]=scientist[i];
    }
    int m;
    cin >> m;
    for (int i = 1; i <= n; i ++ ){
        scanf("%d",&c[i].first);
        point[p++][0]=c[i].first;
    }
    for (int i = 1; i <= n; i ++ ){
        scanf("%d",&c[i].last);
        point[p++][0]=c[i].last;    
    }
    sort(point,point+p);
    int numofpoint=unique(point,point+p)-point;
    for (int i = 0; i < n; i ++ ){
        point[lower_bound(point,point+numofpoint,scientist[i])][1]++;
    }
    int maxha=-1;
    int th;
    for (int i = 0; i < n; i ++ ){
        if(point[lower_bound(point,point+numofpoint,c[i].first)][1]==maxha){
            if((point[lower_bound(point,point+numofpoint,c[i].first)][1])>(point[lower_bound(point,point+numofpoint,c[th].first)][1])){
                th=i;
                continue;
            }
        }else if(point[lower_bound(point,point+numofpoint,c[i].first)][1]>maxha)th=i;
    }
    cout << th;
}

2023/10/15 22:39
加载中...