#include #include using namespace std; #define NMAX 1500 typedef struct s{ long long A,cnt; } S; bool operator<(S a,S b){ return a.A>N; for(long long i=0;i>A[i].A; for(long long i=0;i>B[i]; ansx=-1; ansn=N+1; for(long long i=0;itmp.A||(A[k].A==tmp.A&&A[k].cnt>tmp.cnt)){ A[k-1]=tmp; break; } A[k-1]=A[k]; } } long long maxf=-1; long long minf=N+1; for(long long k=0;kmaxf) maxf=A[k].cnt; if(A[k].cntminf) ansn=minf,ansx=maxf; else if(ansn==minf&&ansx