#include <iostream>
#include <bits/stdc++.h>
#include <string> using namespace std; typedef struct {
   int y;
int result;

}S;
int main()
{
vector<S> s;
int number;
cin>>number;
while(number--)
{
S temp;
cin>>temp.y>>temp.result;
s.push_back(temp);
}
int Maxseita=INT_MIN;int seita;int maxsamenumber=INT_MIN;
for(int i=0;i<s.size();i++)
{
seita=s[i].y;
int samenumber=0;
for(int j=0;j<s.size();j++)
{
if(s[j].y>=seita)
{
if(s[j].result==1)
samenumber++;
}
else
{
if(s[j].result==0)
samenumber++;
} }
if(samenumber>maxsamenumber)
{
maxsamenumber=samenumber;
Maxseita=seita;
}
else if(samenumber==maxsamenumber)
{
if(seita>Maxseita)
{
Maxseita=seita;
}
}
}
cout<<Maxseita;
}

70

100

#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<cstring>
#define mm(a,b) memset(a,b,sizeof(a))
using namespace std;
struct node{
int y;
int result;
};
bool cmp(node a,node b){
return a.y<b.y;
}
vector<node> v;
set<int> s;
node temp;
const int N=1e5+5;
int sum[N];
int best_y,best_num;
int main(){
mm(sum,0); //也可以直接用 int sum[N]={0} 代替
int m;
cin>>m;
for(int i=0;i<m;i++){
cin>>temp.y>>temp.result;
v.push_back(temp);
}
sort(v.begin(),v.end(),cmp);
// 关键来了,就是求挂科前缀和
for(int i=1;i<=m;i++){
sum[i]=sum[i-1]+v[i-1].result;
}
int one,zero;
for(int i=1;i<=m;i++){
temp.y=v[i-1].y;
if(s.count(temp.y)) continue;
s.insert(temp.y);
one=sum[m]-sum[i-1];
zero=i-1-sum[i-1];
temp.result=one+zero;
if(temp.result>=best_num){
best_y=temp.y;
best_num=temp.result;
}
}
cout<<best_y<<endl;
return 0;
}

最新文章

  1. AngularJs的UI组件ui-Bootstrap分享(十一)——Typeahead
  2. android activity改变另一个activity ui
  3. day04关于MySqL&mdash;Android小白的学习笔记
  4. Mac OS 文件、文件夹重命名的方法
  5. python 多线程 笔记(一)
  6. POJ 1466 Girls and Boys 黑白染色 + 二分匹配 (最大独立集) 好题
  7. poj -3262 Protecting the Flowers (贪心)
  8. No Hibernate Session bound to thread, and configuration does not allow creat
  9. Using Live555 to Stream Live Video from an IP camera connected to an H264 encoder
  10. android 47 service绑定
  11. nginx配置文件中的location详解
  12. spring事务不会进行回滚的情况
  13. [转载] Java NIO教程
  14. XMPP系列(六)---创建群组
  15. ExtJS:文件上传实例
  16. Windows Internals 笔记——线程
  17. 我是如何用redis做实时订阅推送的
  18. Logstash使用介绍
  19. Python框架学习之Flask中的常用扩展包
  20. Android补间动画、帧动画和属性动画使用知识介绍

热门文章

  1. Asp.net中web.config配置文件最全面详解 (转载至CSDN)
  2. didi-笔试
  3. clear
  4. sxt_(001_002)_web简介
  5. 前端之Vue day07 混入、插件、elementui、Router、Vuex
  6. java 之 UncaughtExceptionHandler异常处理机制
  7. HashMap问题
  8. zookeeper在关闭服务时报could not find file /opt/module/zookeeper-3.5.10/zkData/zookeeper_server.pid
  9. bsub opts
  10. js单线程工作