# 1040: The Remains of the Day

### 题目描述

"Why, Mr Stevens, why, why, why do you always have to pretend?"

The Remains of the Day by Kazuo Ishiguro

```cpp template<class RandomIt, class Compare> constexpr void sort(RandomIt first, RandomIt last, Compare comp); template<class RandomIt, class Compare> constexpr void nth_element(RandomIt first, RandomIt nth, RandomIt last, Compare comp);```

```cpp

# include "example.hpp"

int a[9] = {1, 5, 6, 2, 7, 3, 9, 4, 8};

bool cmp(const int &x, const int &y){return x > y;}

int main() { nth_element(a, a + 8, a + 9, cmp);//find the 8th(0-base) greatest value in a with cmp as comparator std::cout << *(a + 5) << std::endl;// 4 sort(a, a + 9, {return x < y;});//comp is a lambda expression, which returns true if and only if x < y for (int i = 0;i < 9;++ i) std::cout << a[i] << " ";// 1 2 3 4 5 6 7 8 9 std::cout << std::endl; return 0; } ```

~~一句话题意：手写排序和快速选择。~~

（无）

（无）

（无）

（无）

### 数据范围

`sort` 的正确性占 70 分，`nth_element` 的正确性占 30 分。

## Oops! 本题目还没有解答！

OJ翻了一新，但本解答集还大多用的是2017-2019级，甚至更早的同学们贡献的答案。