比较简单的一题,纠结比较久的是把my_cmp和my_minus放在类中,利用sort函数会出现

no matching function for call to ""sort(std::vector<Interval>::iterator, std::vector<Interval>::iterator, <unresolved overloaded function type>)""

当把这两个函数放在类外面时就行了
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std; typedef pair<int,int> Point;
bool my_cmp(const Point& a, const Point& b){
return a.second < b.second;
} Point my_minus( Point&a, Point& b){
return Point(a.first,a.second-b.second);
} class CatchTheBeatEasy{
public:
string ableToCatchAll(vector<int> x, vector<int> y){
vector<Point> points;
for(int i = ; i < x.size(); ++ i)
points.push_back(make_pair(x[i],y[i]));
sort(points.begin(),points.end(),my_cmp);
adjacent_difference(points.begin(),points.end(),points.begin(),my_minus);
int start = ;
for(int i = ; i< points.size(); ++i){
if(abs(points[i].first-start) > points[i].second) return "Not able to catch";
start = points[i].first;
}
return "Able to catch";
}
};

最新文章

  1. JS对象深刻理解 - 2
  2. Android项目实战(六):JazzyGridView和JazzyListView的使用
  3. Hadoop 数据库 - HBase
  4. S2小测--索引--视图
  5. 像jQuery那样,采用链式方法,封装一个方法:CSS()
  6. sql拼接字符串和转换类型
  7. STORM_0005_第一个非常简单的storm topology的提交运行
  8. Java中Integer的源码学习
  9. MySQL删除外键定义的方法
  10. No suitable authentication method found to complete authentication (publickey,keyboard-interactive).
  11. jQuery自学笔记(四):jQuery DOM节点操作
  12. C语言基础学习基本数据类型-变量的输出与输入
  13. ios 自己定义导航栏和切割线
  14. MUI判断网络连接以及监听网络变化JS
  15. SQL Server 连接 MySQL
  16. 使用ML.NET实现NBA得分预测
  17. [luogu1962]斐波那契数列
  18. 三种方法获取Class对象的区别
  19. day25
  20. 【bzoj1089】严格n元树

热门文章

  1. EF &ndash; 7.一对多关联
  2. 11g 使用rman duplicate复制数据库,创建辅助实例
  3. Swing布局基础
  4. Freemarker遍历map
  5. WPF 多语言实现
  6. VS2010和matlab2010混合编程中char16_t重定义的问题
  7. JQuery.Ajax()的data参数类型
  8. 几个CSS3动画
  9. 智能车学习(四)&mdash;&mdash; Cmp学习
  10. DampView阻尼效果