zoukankan      html  css  js  c++  java
  • 电影【离散化】

    image


      1 #include<bits/stdc++.h>
      2 using namespace std;
      3 
      4 const int MAX = 200010;
      5 int n,mm;
      6 unordered_map<int, int> m;//无序map减少时间复杂度logn
      7 
      8 struct node {
      9     int pos,lan,sub;
     10     bool operator <(const node &num) const//定义优先级
     11     {
     12         if(lan == num.lan) return sub > num.sub;
     13         else return lan > num.lan;
     14     }
     15 }a[MAX];
     16 
     17 inline void init()
     18 {
     19     cin >> n;
     20     for(int i = 1;i <= n;++i)
     21     {
     22         int x;
     23         cin >> x;
     24         m[x]++;
     25     }
     26 
     27     cin >> mm;
     28     for(int i = 1;i <= mm;++i)
     29     {
     30         int x;
     31         cin >> x;
     32         a[i].pos = i;
     33         a[i].lan = m[x];
     34     }
     35 
     36     for(int i = 1;i <= mm;++i)
     37     {
     38         int x;
     39         cin >> x;
     40         a[i].sub = m[x];
     41     }
     42 }
     43 
     44 inline void find()
     45 {
     46     sort(a+1,a+mm+1);
     47     cout << a[1].pos;
     48 }
     49 
     50 int main(void)
     51 {
     52     ios::sync_with_stdio(false);
     53     cin.tie(0);
     54     init();
     55 
     56     find();
     57 
     58     return 0;
     59 }
     60 
     61 
    追求吾之所爱
  • 相关阅读:
    【项目】项目1
    Python脚本1
    Python基础24
    Python基础23(习惯)
    01-Spring(1)
    12-Shell(2)
    11-Shell(1)
    10-搭建EE环境
    09-常用指令(3)
    08-常用指令(2)
  • 原文地址:https://www.cnblogs.com/rstz/p/12695918.html
Copyright © 2011-2022 走看看